diff --git a/pages.json b/pages.json index c77c0e49bf20e0830b773eedd093b39fb805e8b7..d50481561bef25181f4bfc49f946e5889a3b69ba 100644 --- a/pages.json +++ b/pages.json @@ -561,6 +561,12 @@ "navigationBarTitleText": "pageScrollTo", "enablePullDownRefresh": false } + }, { + "path": "pages/API/event-bus/event-bus", + "style": { + "navigationBarTitleText": "event-bus", + "enablePullDownRefresh": false + } }, { "path": "pages/template/drop-card/drop-card", "style": { diff --git a/pages/API/event-bus/event-bus.test.js b/pages/API/event-bus/event-bus.test.js new file mode 100644 index 0000000000000000000000000000000000000000..35d3e36644cf81c5be73373ec095c365021de612 --- /dev/null +++ b/pages/API/event-bus/event-bus.test.js @@ -0,0 +1,54 @@ +const PAGE_PATH = '/pages/API/event-bus/event-bus' + +describe('event-bus', () => { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + }) + + it('on', async () => { + await page.callMethod('clear') + await page.callMethod('on') + await page.callMethod('emit') + const l1 = (await page.data()).log.length + expect(l1).toBe(1) + await page.callMethod('clear') + await page.callMethod('emit') + const l2 = (await page.data()).log.length + expect(l2).toBe(1) + await page.callMethod('clear') + await page.callMethod('on') + await page.callMethod('emit') + const l3 = (await page.data()).log.length + expect(l3).toBe(2) + await page.callMethod('clear') + await page.callMethod('off') + await page.callMethod('emit') + const l4 = (await page.data()).log.length + expect(l4).toBe(1) + await page.callMethod('clear') + await page.callMethod('off') + await page.callMethod('emit') + const l5 = (await page.data()).log.length + expect(l5).toBe(0) + }) + + it('once', async () => { + await page.callMethod('clear') + await page.callMethod('once') + await page.callMethod('emit') + const l1 = (await page.data()).log.length + expect(l1).toBe(1) + await page.callMethod('clear') + await page.callMethod('emit') + const l2 = (await page.data()).log.length + expect(l2).toBe(0) + await page.callMethod('clear') + await page.callMethod('once') + await page.callMethod('off') + await page.callMethod('emit') + const l3 = (await page.data()).log.length + expect(l3).toBe(0) + }) +}) diff --git a/pages/API/event-bus/event-bus.uvue b/pages/API/event-bus/event-bus.uvue new file mode 100644 index 0000000000000000000000000000000000000000..6abf994423dcf2b4dba93b7841d277901c711efa --- /dev/null +++ b/pages/API/event-bus/event-bus.uvue @@ -0,0 +1,51 @@ + + + + + \ No newline at end of file diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index 5bdca3faa88752418096bd7ea9c6f755c4479576..1df2ac71f89ab8175c9a14560f1e24d805671a4b 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -456,6 +456,14 @@ url: "/platforms/app-plus/push/push", }, ] as Page[], + }, + { + id: "event-bus", + name: "event-bus", + open: false, + enable: true, + url: "event-bus", + pages: [] as Page[], }, //#endif ] as ListItem[],