diff --git a/pages/API/inner-audio/inner-audio.test.js b/pages/API/inner-audio/inner-audio.test.js new file mode 100644 index 0000000000000000000000000000000000000000..8538001be721977a23945a5ab6923390a9931be0 --- /dev/null +++ b/pages/API/inner-audio/inner-audio.test.js @@ -0,0 +1,74 @@ +describe('inner-audio', () => { + if (!process.env.uniTestPlatformInfo.startsWith('web')) { + it('app', () => { + expect(1).toBe(1) + }) + return + } + beforeAll(async () => { + page = await program.reLaunch('/pages/API/inner-audio/inner-audio') + await page.waitFor('view'); + }); + + function getData(key = '') { + return new Promise(async (resolve, reject) => { + const data = await page.data() + resolve(key ? data[key] : data) + }) + } + + it('onCanplay',async()=>{ + await page.waitFor(1000) + await page.waitFor(async()=>{ + return await getData('isCanplay') + }) + console.log("获取缓冲信息",await getData('buffered')) + expect(await getData('buffered')).toBeGreaterThan(0) + }) + + it('play-onPlay-onTimeUpdate', async () => { + await page.callMethod('play') + await page.waitFor(3000); + expect(await getData('isPlaying')).toBeTruthy() + console.log("duration:",await getData('duration'),"currentTime:",await getData('currentTime')) + expect(await getData('duration')).toBe(175.109) + // console.log("isPaused",await getData('isPaused')) + // expect(await getData('currentTime')).toBeGreaterThan(0); + // expect(await getData('isPaused')).toBeFalsy(); + }); + + it('seek-onSeeking-onSeeked', async () => { + await page.callMethod('onchange',20) + await page.waitFor(500); + expect(await getData('onSeekingTest')).toBeTruthy(); + // expect(await getData('onWaitingTest')).toBeTruthy(); + expect(await getData('onSeekedTest')).toBeTruthy(); + }); + + it('pause-onPause', async () => { + await page.callMethod('pause') + await page.waitFor(500); + expect(await getData('isPlaying')).toBeFalsy() + // expect(await getData('isPaused')).toBeTruthy(); + }); + + it('stop-onStop', async () => { + await page.callMethod('play') + await page.waitFor(2000); + // 第一次点停止时,不触发onStop事件 + await page.callMethod('stop') + await page.callMethod('stop') + await page.waitFor(1000); + expect(await getData('isPlaying')).toBeFalsy() + // expect(await getData('isPaused')).toBeTruthy(); + }); + + it('onEnded', async () => { + await page.callMethod('onchange',173) + await page.waitFor(500); + await page.callMethod('play') + await page.waitFor(3000); + // expect(await getData('isPlayEnd')).toBeTruthy(); + }); + +}); diff --git a/pages/API/inner-audio/inner-audio.uvue b/pages/API/inner-audio/inner-audio.uvue index 093c831ec7a7768072ab8b18ff044f3b42bec0c9..bf4991c4d681a35964e11ad3357511375b42cd32 100644 --- a/pages/API/inner-audio/inner-audio.uvue +++ b/pages/API/inner-audio/inner-audio.uvue @@ -1,22 +1,34 @@ diff --git a/pages/component/movable-view/movable-view.test.js b/pages/component/movable-view/movable-view.test.js new file mode 100644 index 0000000000000000000000000000000000000000..eb25b97b744d89a7ff6bed0de1ce94e07e00f25d --- /dev/null +++ b/pages/component/movable-view/movable-view.test.js @@ -0,0 +1,30 @@ +let page; +describe('movable-view.uvue', () => { + console.log(process.env.uniTestPlatformInfo,process.env.uniTestPlatformInfo.startsWith('web')) + if (!process.env.uniTestPlatformInfo.startsWith('web')) { + it('app', () => { + expect(1).toBe(1) + }) + return + } + beforeAll(async () => { + page = await program.reLaunch('/pages/component/movable-view/movable-view') + await page.waitFor('view'); + }); + + it('移动至 (30px, 30px)', async () => { + expect(await page.data('x')).toBe(0) + expect(await page.data('y')).toBe(0) + await page.callMethod('tap') + await page.waitFor(500); + expect(await page.data('x')).toBe(30) + expect(await page.data('y')).toBe(30) + }) + it('放大3倍', async () => { + expect(await page.data('scale')).toBe(2) + await page.callMethod('tap2') + await page.waitFor(500); + expect(await page.data('scale')).toBe(3) + }) + +})