From da22ce7333a14249eb25a58d1cfad47f135c6c7a Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Thu, 7 Dec 2023 14:59:00 +0800 Subject: [PATCH] feat: v-memo --- pages.json | 6 ++++ pages/directive/v-memo/v-memo.test.js | 52 +++++++++++++++++++++++++++ pages/directive/v-memo/v-memo.uvue | 38 ++++++++++++++++++++ pages/index.uvue | 14 ++++++-- 4 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 pages/directive/v-memo/v-memo.test.js create mode 100644 pages/directive/v-memo/v-memo.uvue diff --git a/pages.json b/pages.json index d2ab84b..791fb89 100644 --- a/pages.json +++ b/pages.json @@ -96,6 +96,12 @@ "navigationBarTitleText": "v-once" } }, + { + "path": "pages/directive/v-memo/v-memo", + "style": { + "navigationBarTitleText": "v-memo" + } + }, { "path": "pages/directive/v-show/v-show", "style": { diff --git a/pages/directive/v-memo/v-memo.test.js b/pages/directive/v-memo/v-memo.test.js new file mode 100644 index 0000000..9c12e52 --- /dev/null +++ b/pages/directive/v-memo/v-memo.test.js @@ -0,0 +1,52 @@ +const PAGE_PATH = '/pages/directive/v-memo/v-memo' + +describe('v-memo', () => { + if (process.env.uniTestPlatformInfo.startsWith('android')) { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const equivalentVOnceTextEl = await page.$('.equivalent-v-once-text') + let equivalentVOnceTextText = await equivalentVOnceTextEl.text() + expect(equivalentVOnceTextText).toBe( + 'This will never change: hello world' + ) + + const vMemoTextEl = await page.$('.v-memo-text') + let vMemoTextText = await vMemoTextEl.text() + expect(vMemoTextText).toBe( + 'This will change when num change, msg: hello world, num: 0' + ) + + const changeMessageBtn = await page.$('.change-message-btn') + await changeMessageBtn.tap() + + const msg = await page.data('msg') + expect(msg).toBe('msg changed') + + equivalentVOnceTextText = await equivalentVOnceTextEl.text() + expect(equivalentVOnceTextText).toBe( + 'This will never change: hello world' + ) + vMemoTextText = await vMemoTextEl.text() + expect(vMemoTextText).toBe( + 'This will change when num change, msg: hello world, num: 0' + ) + + const plusNumBtn = await page.$('.plus-num-btn') + await plusNumBtn.tap() + + vMemoTextText = await vMemoTextEl.text() + expect(vMemoTextText).toBe( + 'This will change when num change, msg: msg changed, num: 1' + ) + }) + } else { + // TODO: web 端暂不支持 + it('web', async () => { + expect(1).toBe(1) + }) + } +}) diff --git a/pages/directive/v-memo/v-memo.uvue b/pages/directive/v-memo/v-memo.uvue new file mode 100644 index 0000000..0d64de1 --- /dev/null +++ b/pages/directive/v-memo/v-memo.uvue @@ -0,0 +1,38 @@ + + + diff --git a/pages/index.uvue b/pages/index.uvue index 80c8406..44e97c5 100644 --- a/pages/index.uvue +++ b/pages/index.uvue @@ -173,12 +173,22 @@ { name: 'v-once', url: 'v-once', - enable: true, + // #ifdef APP-ANDROID + enable: true, + // #endif + // #ifndef APP-ANDROID + enable: false, + // #endif }, { name: 'v-memo', url: 'v-memo', - enable: false, + // #ifdef APP-ANDROID + enable: true, + // #endif + // #ifndef APP-ANDROID + enable: false, + // #endif }, { name: 'v-cloak', -- GitLab