custom_variable.test.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  2. const isAndroid = platformInfo.startsWith("android")
  3. const isIos = platformInfo.startsWith("ios")
  4. const isWeb = platformInfo.startsWith("web")
  5. const isMP = platformInfo.startsWith('mp')
  6. let page
  7. describe("css-custom-variable", () => {
  8. if (isMP) {
  9. it('skip mp', () => {
  10. expect(1).toBe(1)
  11. })
  12. return
  13. }
  14. it("screenshot", async () => {
  15. page = await program.reLaunch("/pages/CSS/variable/custom_variable")
  16. await page.waitFor("view")
  17. const image = await program.screenshot({
  18. fullPage: true,
  19. })
  20. expect(image).toSaveImageSnapshot()
  21. })
  22. // 点击 .test-v-if-button 按钮,查询 .test-v-if 元素高度
  23. it("test-v-if", async () => {
  24. await page.waitFor("view")
  25. const element = await page.$(".test-v-if")
  26. const {
  27. height: height1
  28. } = await element.size()
  29. expect(height1).toBe(0)
  30. const button = await page.$(".test-v-if-button")
  31. await button.tap()
  32. await page.waitFor(500)
  33. const {
  34. height: height2
  35. } = await element.size()
  36. expect(height2).toBe(30)
  37. })
  38. // 先查询 #chanageVarBox 的高度并记录
  39. // 点击 #changeVarButton,查询 #chanageVarBox 的高度,和之前高度应当不一样
  40. it("test-change-var", async () => {
  41. const element = await page.$("#chanageVarBox")
  42. const {
  43. height: height1
  44. } = await element.size()
  45. expect(height1 > 0).toBe(true)
  46. const button = await page.$("#changeVarButton")
  47. await button.tap()
  48. await page.waitFor(500)
  49. const {
  50. height: height2
  51. } = await element.size()
  52. expect(height2 == height1).toBe(false)
  53. })
  54. })