From 219829661e918c22576bd810a418fa3a1ca33136 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Tue, 16 Jan 2024 18:03:56 +0800 Subject: [PATCH] feat(composition api): toValue --- .../reactivity/to-value/to-value.test.js | 36 +++++++++++++++++++ .../reactivity/to-value/to-value.uvue | 34 +++++++++++++++++- pages/tab-bar/composition-api.uvue | 2 +- 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 pages/composition-api/reactivity/to-value/to-value.test.js diff --git a/pages/composition-api/reactivity/to-value/to-value.test.js b/pages/composition-api/reactivity/to-value/to-value.test.js new file mode 100644 index 0000000..2754d9a --- /dev/null +++ b/pages/composition-api/reactivity/to-value/to-value.test.js @@ -0,0 +1,36 @@ +const PAGE_PATH = '/pages/composition-api/reactivity/to-value/to-value' + +describe('toValue', () => { + if (process.env.uniTestPlatformInfo.startsWith('android')) { + let page = null + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const refCount = await page.$('#ref-count') + expect(await refCount.text()).toBe('ref count: 0') + const isRefRefCount = await page.$('#is-ref-ref-count') + expect(await isRefRefCount.text()).toBe('isRef ref count: true') + const count = await page.$('#count') + expect(await count.text()).toBe('count: 0') + const isRefCount = await page.$('#is-ref-count') + expect(await isRefCount.text()).toBe('isRef count: false') + + const objNum = await page.$('#obj-num') + expect(await objNum.text()).toBe('obj.num: 0') + const toValueObjNum = await page.$('#to-value-obj-num') + expect(await toValueObjNum.text()).toBe('toValue(() => obj.num): 0') + + const incrementBtn = await page.$('#increment-btn') + await incrementBtn.tap() + + expect(await objNum.text()).toBe('obj.num: 1') + expect(await toValueObjNum.text()).toBe('toValue(() => obj.num): 1') + }) + } else { + it('other platform', () => { + expect(1).toBe(1) + }) + } +}) \ No newline at end of file diff --git a/pages/composition-api/reactivity/to-value/to-value.uvue b/pages/composition-api/reactivity/to-value/to-value.uvue index 2350234..1c70c8a 100644 --- a/pages/composition-api/reactivity/to-value/to-value.uvue +++ b/pages/composition-api/reactivity/to-value/to-value.uvue @@ -1 +1,33 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/pages/tab-bar/composition-api.uvue b/pages/tab-bar/composition-api.uvue index f7734ce..1fdf26d 100644 --- a/pages/tab-bar/composition-api.uvue +++ b/pages/tab-bar/composition-api.uvue @@ -141,7 +141,7 @@ { name: 'toValue', url: 'to-value', - enable: false, + enable: true, }, { name: 'toRefs', -- GitLab