element-get-attribute.test.js 1.4 KB
Newer Older
Anne_LXM's avatar
Anne_LXM 已提交
1
jest.setTimeout(30000);
2 3 4
describe('test element-get-attribute', () => {
  let page,platform,attrStyle,propertyValue;
  platform = process.env.UNI_PLATFORM
Anne_LXM's avatar
Anne_LXM 已提交
5 6 7 8 9 10 11 12 13 14
  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')
15 16
    if(platform != 'app-plus'){
      await page.callMethod('getAttributeStyle')
17
      console.log('attrStyle:',await page.data('attrStyle'))
18 19 20
      attrStyle = platform == 'mp-weixin'?'background-color:#FFF000;':'padding: 0.625rem; background-color: rgb(255, 240, 0);'
      expect(await page.data('attrStyle')).toEqual(attrStyle);
    }
Anne_LXM's avatar
Anne_LXM 已提交
21
  });
22 23 24 25
  it('check getPropertyValue', async () => {
    await page.callMethod('getPropertyValue')
    propertyValue = platform == 'h5'?'rgb(255, 240, 0)':'#FFF000'
    expect(await page.data('propertyValue')).toEqual(propertyValue);
Anne_LXM's avatar
Anne_LXM 已提交
26
  });
27 28 29 30 31 32 33 34
  if(platform != 'h5'){
    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 已提交
35
});