From e212aa66257b4589d8c591db153c89ec35b5f66d Mon Sep 17 00:00:00 2001 From: jixinbao Date: Tue, 6 Aug 2024 13:43:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85=20canvas=20context?= =?UTF-8?q?=20=E6=96=B9=E6=B3=95=E6=BC=94=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/canvas/canvas.test.js | 25 +- pages/component/canvas/canvas.uvue | 905 +++++++++++++++++++++++++- 2 files changed, 887 insertions(+), 43 deletions(-) diff --git a/pages/component/canvas/canvas.test.js b/pages/component/canvas/canvas.test.js index 97580874..890fb836 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 10ecb233..0ff092dd 100644 --- a/pages/component/canvas/canvas.uvue +++ b/pages/component/canvas/canvas.uvue @@ -1,9 +1,21 @@