From 929efbf2b48622e85223d9bd9ddbaa131cfa8d33 Mon Sep 17 00:00:00 2001 From: toxic-johann <353904974@qq.com> Date: Wed, 8 Nov 2017 00:21:18 +0800 Subject: [PATCH] [update] add test but it fail --- __tests__/bugfix.js | 18 ++++++++++++++++++ __tests__/dispatcher/plugin.js | 4 ++-- __tests__/index.js | 2 +- __tests__/silentload.js | 34 ++++++++++++++++++++++++++++++++++ demo/flv/index.html | 2 +- demo/flv/index.js | 10 ++++++++-- package.json | 2 +- src/dispatcher/index.js | 14 +++++--------- 8 files changed, 70 insertions(+), 16 deletions(-) diff --git a/__tests__/bugfix.js b/__tests__/bugfix.js index 7db8030a..850bb6e0 100644 --- a/__tests__/bugfix.js +++ b/__tests__/bugfix.js @@ -1,4 +1,5 @@ import Chimee from 'index'; +import chimeeKernelFlv from 'chimee-kernel-flv'; test('redudant event bind on video', () => { const wrapper = document.createElement('div'); const fn = jest.fn(); @@ -38,3 +39,20 @@ test('non extendable should not be set on dispatcher.plugins', () => { plugin: ['nonextendablePlugins'] })).not.toThrow(); }); + +test('load should use default preset and kernels if people do not pass one', () => { + const wrapper = document.createElement('div'); + const chimee = new Chimee({ + src: + 'http://yunxianchang.live.ujne7.com/vod-system-bj/TL1ce1196bce348070bfeef2116efbdea6.flv', + isLive: false, + kernels: { + flv: chimeeKernelFlv + }, + // 编解码容器 + box: 'flv', // flv hls native + // dom容器 + wrapper, + }); + expect(() => chimee.load('http://yunxianchang.live.ujne7.com/vod-system-bj/TL1ce1196bce348070bfeef2116efbdea6.flv')).not.toThrow(); +}); diff --git a/__tests__/dispatcher/plugin.js b/__tests__/dispatcher/plugin.js index 2ff205dc..0658998d 100644 --- a/__tests__/dispatcher/plugin.js +++ b/__tests__/dispatcher/plugin.js @@ -24,7 +24,7 @@ describe('dispatcher/plugin', () => { } }; dispatcher.dom = new Dom(wrapper, dispatcher); - dispatcher.videoConfig = new VideoConfig(dispatcher, {}) + dispatcher.videoConfig = new VideoConfig(dispatcher, {}); dispatcher.bus = new Bus(dispatcher); Log.data.error = []; Log.data.warn = []; @@ -665,7 +665,7 @@ describe('dispatcher/plugin', () => { const plugin = new Plugin({ id: 'err', inited () { - return new Promise(() => {throw error;}) + return new Promise(() => {throw error;}); } }, dispatcher); let catcherr = false; diff --git a/__tests__/index.js b/__tests__/index.js index 5b171e16..e5d4208a 100644 --- a/__tests__/index.js +++ b/__tests__/index.js @@ -2,7 +2,7 @@ import Chimee from 'index'; import {Log, getAttr, setAttr} from 'chimee-helper'; import {videoReadOnlyProperties} from 'helper/const'; import esFullscreen from 'es-fullscreen'; -import chimeeKernelFlv from 'chimee-kernel-flv'; +// import chimeeKernelFlv from 'chimee-kernel-flv'; describe('Chimee', () => { const normalInstall = { diff --git a/__tests__/silentload.js b/__tests__/silentload.js index 28b537ee..ce59a02c 100644 --- a/__tests__/silentload.js +++ b/__tests__/silentload.js @@ -1,5 +1,6 @@ import Chimee from 'index'; import ChimeeKernelHls from 'chimee-kernel-hls'; +// import ChimeeKernelFlv from 'chimee-kernel-flv'; import {bind, Log} from 'chimee-helper'; describe('$silentLoad', () => { let player; @@ -29,6 +30,39 @@ describe('$silentLoad', () => { global.document.createElement = originFn; player.destroy(); }); + // test('silentload should use default preset and kernels if people do not pass one', async () => { + // const wrapper = document.createElement('div'); + // player = new Chimee({ + // src: + // 'http://yunxianchang.live.ujne7.com/vod-system-bj/TL1ce1196bce348070bfeef2116efbdea6.flv', + // isLive: false, + // preset: { + // flv: ChimeeKernelFlv + // }, + // // 编解码容器 + // box: 'flv', // flv hls native + // // dom容器 + // wrapper + // }); + // oldVideo = player.__dispatcher.dom.videoElement; + // oldKernel = player.__dispatcher.kernel; + // const result = player.silentLoad( + // 'http://yunxianchang.live.ujne7.com/vod-system-bj/TL1ce1196bce348070bfeef2116efbdea6.flv', + // { + // immediate: true + // } + // ); + // // simulate timeupdate beforechange + // oldVideo.dispatchEvent(new Event('timeupdate')); + // // simulate metadata loaded finished + // video.dispatchEvent(new Event('loadedmetadata')); + // // simulate canplayable + // video.dispatchEvent(new Event('canplay')); + // // simulate times up + // player.currentTime = 3; + // oldVideo.dispatchEvent(new Event('timeupdate')); + // await expect(result).resolves.toBe(); + // }); test('normal run', async () => { const result = player.$silentLoad('http://cdn.toxicjohann.com/%E4%BA%8E%E6%98%AF.mp4'); await Promise.resolve(); diff --git a/demo/flv/index.html b/demo/flv/index.html index 85ee9231..189be7a5 100644 --- a/demo/flv/index.html +++ b/demo/flv/index.html @@ -18,7 +18,7 @@