video.test.js 1.4 KB
Newer Older
1
describe('component-native-video', () => {
2 3 4 5 6 7 8
  if(process.env.uniTestPlatformInfo.startsWith('web')){
    // TODO: web 端暂不支持测试
    it('web', async () => {
      expect(1).toBe(1)
    })
    return
  }
9 10
  let page;
  beforeAll(async () => {
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
11
    page = await program.reLaunch('/pages/component/video/video');
12 13 14 15 16
    if(process.env.uniTestPlatformInfo.startsWith('web')){
      await page.setData({
        muted: true
      });
    }
17
    await page.waitFor(1000);
18 19 20
  });

  it('test API', async () => {
21
    expect(await page.data('isError')).toBe(false);
22 23
    // play
    await page.callMethod('play');
24 25
    await page.waitFor(100);
    expect(await page.data('isPlaying')).toBe(true);
26 27
    // pause
    await page.callMethod('pause');
28 29
    await page.waitFor(100);
    expect(await page.data('isPause')).toBe(true);
30 31
  });

32 33 34 35 36 37 38 39 40 41 42 43 44 45
  it('test local source', async () => {
  	  await page.callMethod('downloadSource');
  	  await page.waitFor(5000);
  	  expect(await page.data('isError')).toBe(false);
  	  await page.setData({
  		  localSrc: '/static/test-video/2minute-demo.m3u8'
  	  });
  	  await page.waitFor(100);
  	  expect(await page.data('isError')).toBe(false);
  	  await page.setData({
  		  autoTest: false
  	  });
  });

46
  it('test format', async () => {
47
    page = await program.navigateTo('/pages/component/video/video-format');
48 49 50 51
    await page.waitFor(1000);
    expect(await page.data('isError')).toBe(false);
  });
});