video.test.js 1.2 KB
Newer Older
1
describe('component-native-video', () => {
2

3 4
  let page;
  beforeAll(async () => {
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
5
    page = await program.reLaunch('/pages/component/video/video');
6 7 8 9 10
    if(process.env.uniTestPlatformInfo.startsWith('web')){
      await page.setData({
        muted: true
      });
    }
11
    await page.waitFor(1000);
12 13 14
  });

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

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

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