rich-text.test.js 2.6 KB
Newer Older
1 2
const PAGE_PATH = '/pages/component/rich-text/rich-text'

3 4 5 6 7 8
describe('rich-text-test', () => {
  const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  const isAndroid = platformInfo.startsWith('android')
  const isIOS = platformInfo.startsWith('ios')
  const isMP = platformInfo.startsWith('mp')
  const isWeb = platformInfo.startsWith('web')
9

10
  if (isWeb || isMP) {
11 12 13 14 15
    it('other platform', () => {
      expect(1).toBe(1)
    })
    return
  }
16 17 18 19 20 21

  let page
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(1500);
  })
22 23 24 25


  it('richt-text-height', async () => {
    let beforeValue = await page.data('richTextHeight')
26
    if (beforeValue < 10) {
27
      await page.waitFor(2000)
28
      beforeValue = await page.data('richTextHeight')
29 30 31 32 33

      if (beforeValue < 10) {
        await page.waitFor(2000)
        beforeValue = await page.data('richTextHeight')
      }
34
    }
35 36 37
    await page.callMethod('changeText')
    await page.waitFor(500)
    await page.callMethod('changeText')
38
    await page.waitFor(1000)
39 40 41 42 43
    let afterValue = await page.data('richTextHeight')
    console.log('beforeValue:', beforeValue)
    console.log('afterValue:', afterValue)
    expect(beforeValue).toBe(afterValue)
  })
44 45

  it('test selectable itemclick', async () => {
46 47 48
    if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
      return;
    }
49 50 51 52 53 54 55 56 57 58 59 60 61
    await page.setData({
      autoTest: true,
      isItemClickTrigger: false
    });
    await page.waitFor(1000);
    const info = await page.callMethod('getWindowInfoForTest');
    const rect = await page.callMethod('getBoundingClientRectForTest');
    await program.tap({
      x: (rect.right - rect.left) / 2,
      y: info.statusBarHeight + 44 + (rect.bottom - rect.top) / 2
    });
    await page.waitFor(1000);
    expect(await page.data('isItemClickTrigger')).toBe(true);
62 63 64 65 66 67 68 69 70 71 72 73
    await page.setData({
      isItemClickTrigger: false
    });
    await program.navigateTo("/pages/component/rich-text/rich-text-tags");
    await page.waitFor(500);
    await program.navigateBack();
    await program.tap({
      x: (rect.right - rect.left) / 2,
      y: info.statusBarHeight + 44 + (rect.bottom - rect.top) / 2
    });
    await page.waitFor(1000);
    expect(await page.data('isItemClickTrigger')).toBe(true);
74 75 76 77
    await page.setData({
      autoTest: false
    });
  });
78 79 80 81 82 83 84 85 86 87

  it('rich-text parent click', async () => {
    const element = await page.$('#rich-text-parent')
    await element.tap()
    await page.waitFor(500)
    const element2 = await page.$('#rich-text-str')
    expect(await element2.text()).toBe("true")
  })

})