diff --git a/pages/component/canvas/canvas.test.js b/pages/component/canvas/canvas.test.js index 975808745bdd04e2bbf0c384a807eeb70fbf3144..890fb8368832b61f71bc141fb8b3a5ff4f74d1ed 100644 --- a/pages/component/canvas/canvas.test.js +++ b/pages/component/canvas/canvas.test.js @@ -23,21 +23,20 @@ describe('Canvas.uvue', () => { expect(true).toBe(true) } }) - it("测试异步方式", async () => { + it("测试异步创建canvas上下文", async () => { await page.callMethod('useAsync'); - const { - testCanvasContext, - testToDataURLResult - } = await page.data() - expect(testCanvasContext).toBe(true) - await page.callMethod('canvasToDataURL'); - expect(testToDataURLResult).toBe(true) + const element = await page.$('#testCanvasContext') + expect(await element.text()).toBe('true') + + }) + it("测试同步创建canvas上下文", async () => { + await page.callMethod('useAsync'); + const element = await page.$('#testCanvasContext') + expect(await element.text()).toBe('true') }) - it("测试同步方式", async () => { - await page.callMethod('useSync'); - const data = await page.data() - expect(data.testCanvasContext).toBe(true) + it('测试 canvasToDataURL', async () => { await page.callMethod('canvasToDataURL'); - expect(data.testToDataURLResult).toBe(true) + const element = await page.$('#testToDataURLResult') + expect(await element.text()).toBe('true') }) }) diff --git a/pages/component/canvas/canvas.uvue b/pages/component/canvas/canvas.uvue index 10ecb23319824864cca7a84902390abf73c46f35..0ff092dd299cf74fbed87340faef517772e32493 100644 --- a/pages/component/canvas/canvas.uvue +++ b/pages/component/canvas/canvas.uvue @@ -1,9 +1,21 @@