element-get-attribute.test.js 1.6 KB
Newer Older
Anne_LXM's avatar
Anne_LXM 已提交
1
jest.setTimeout(30000);
2
describe('test element-get-attribute', () => {
Anne_LXM's avatar
Anne_LXM 已提交
3 4 5 6 7 8 9
  let page;
  const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  const isAndroid = platformInfo.startsWith('android')
  const isIos = platformInfo.startsWith('ios')
  const isApp = isAndroid || isIos
  const isWeb = platformInfo.startsWith('web')
  const isMP = platformInfo.startsWith('mp')
Anne_LXM's avatar
Anne_LXM 已提交
10 11 12 13 14 15 16 17 18 19
  beforeAll(async () => {
    page = await program.reLaunch('/pages/API/element-get-attribute/element-get-attribute')
    await page.waitFor(3000);
  });
  it('check getAttributeId', async () => {
    await page.callMethod('getAttributeId')
    expect(await page.data('attrId')).toEqual('box');
  });
  it('check setStyle getAttributeStyle', async () => {
    await page.callMethod('setStyle')
Anne_LXM's avatar
Anne_LXM 已提交
20
    if(isWeb||isMP){
21
      await page.callMethod('getAttributeStyle')
22
      console.log('attrStyle:',await page.data('attrStyle'))
Anne_LXM's avatar
Anne_LXM 已提交
23
      const attrStyle = isMP?'background-color:#FFF000;':'padding: 0.625rem; background-color: rgb(255, 240, 0);'
24 25
      expect(await page.data('attrStyle')).toEqual(attrStyle);
    }
Anne_LXM's avatar
Anne_LXM 已提交
26
  });
27 28
  it('check getPropertyValue', async () => {
    await page.callMethod('getPropertyValue')
Anne_LXM's avatar
Anne_LXM 已提交
29
    const propertyValue = isWeb?'rgb(255, 240, 0)':'#FFF000'
30
    expect(await page.data('propertyValue')).toEqual(propertyValue);
Anne_LXM's avatar
Anne_LXM 已提交
31
  });
Anne_LXM's avatar
Anne_LXM 已提交
32
  if(isApp||isMP){
33 34 35 36 37 38 39
    it('check scrollTo', async () => {
      await page.callMethod('scrollTo')
      await page.waitFor(100);
      const scrollView =  await page.$('.scroll-view_H')
      expect(await scrollView.property('scrollLeft')).toBe(200);
    });
  }
Anne_LXM's avatar
Anne_LXM 已提交
40
});