video.test.js 1.3 KB
Newer Older
1
describe('component-native-video', () => {
雪洛's avatar
雪洛 已提交
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
    await page.waitFor(1000);
13 14 15
  });

  it('test API', async () => {
16
    expect(await page.data('isError')).toBe(false);
17 18
    // play
    await page.callMethod('play');
19 20
    await page.waitFor(100);
    expect(await page.data('isPlaying')).toBe(true);
21 22
    // pause
    await page.callMethod('pause');
23 24
    await page.waitFor(100);
    expect(await page.data('isPause')).toBe(true);
25 26
  });

27 28 29 30 31 32 33 34 35 36 37 38 39 40
  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
  	  });
  });

41
  it('test format', async () => {
42
    page = await program.navigateTo('/pages/component/video/video-format');
43 44 45 46
    await page.waitFor(1000);
    expect(await page.data('isError')).toBe(false);
  });
});