From a162a1bf32b09b12f808183acaf0d31872b9f027 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Tue, 5 Nov 2024 11:39:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85=20$emit=20=E6=97=A0?= =?UTF-8?q?=E5=8F=82=E5=8F=8A=E5=A4=9A=E5=8F=82=E6=95=B0=E6=83=85=E5=86=B5?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E5=8F=8A=E6=B5=8B=E8=AF=95=20issue:11588?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/event-bus/event-bus.test.js | 17 +++ pages/API/event-bus/event-bus.uvue | 164 ++++++++++++++------------ 2 files changed, 107 insertions(+), 74 deletions(-) diff --git a/pages/API/event-bus/event-bus.test.js b/pages/API/event-bus/event-bus.test.js index 0e5d3774..bab1af88 100644 --- a/pages/API/event-bus/event-bus.test.js +++ b/pages/API/event-bus/event-bus.test.js @@ -86,4 +86,21 @@ describe('event-bus', () => { expect(logs[0]).toBe('触发 test-return-id $on fn') expect(logs[1]).toBe('触发 test-return-id $once fn') }) + it('test $emit no args', async () => { + await page.callMethod('clear') + expect((await page.data()).log.length).toBe(0) + await page.callMethod('testEmitNoArgs') + const logs = await page.data('log') + expect(logs.length).toBe(1) + expect(logs[0]).toBe('test-emit-no-args') + }) + it('test $emit multiple args', async () => { + await page.callMethod('clear') + expect((await page.data()).log.length).toBe(0) + await page.callMethod('testEmitMultipleArgs') + const logs = await page.data('log') + expect(logs.length).toBe(1) + expect(logs[0]).toBe('arg1_2') + }) + }) diff --git a/pages/API/event-bus/event-bus.uvue b/pages/API/event-bus/event-bus.uvue index 99395dd7..d44718b6 100644 --- a/pages/API/event-bus/event-bus.uvue +++ b/pages/API/event-bus/event-bus.uvue @@ -1,96 +1,112 @@ -- GitLab