From 4d404eb0f88a944e5fae7639ea8017ad91a45e32 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Thu, 18 Jan 2024 20:25:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(composition=20api):=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E5=8F=8A=E6=B5=8B=E8=AF=95=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=20=20web?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/define-emits/array-literal.uvue | 2 +- .../basic/define-emits/define-emits.test.js | 69 ++- .../basic/define-emits/type-emits-1.uvue | 2 +- .../basic/define-emits/type-emits-2.uvue | 2 +- .../define-options/define-options.test.js | 48 +- .../basic/define-options/define-options.uvue | 2 +- .../basic/define-props/define-props.test.js | 108 ++-- .../basic/define-slots/define-slots.test.js | 36 +- .../basic/use-attrs/use-attrs.test.js | 29 +- .../reactivity/computed/computed.test.js | 49 +- .../reactivity/computed/computed.uvue | 2 +- .../reactivity/is-ref/is-ref.test.js | 38 +- .../reactivity/ref/ref.test.js | 43 +- pages/composition-api/reactivity/ref/ref.uvue | 2 +- .../shallow-reactive/shallow-reactive.test.js | 42 +- .../shallow-reactive/shallow-reactive.uvue | 6 +- .../shallow-ref/shallow-ref.test.js | 44 +- .../reactivity/shallow-ref/shallow-ref.uvue | 4 +- .../reactivity/un-ref/un-ref.test.js | 36 +- .../watch-effect/watch-effect.test.js | 219 +++++--- .../reactivity/watch-effect/watch-effect.uvue | 6 +- .../reactivity/watch/watch.test.js | 266 ++++++---- .../reactivity/watch/watch.uvue | 6 +- pages/tab-bar/composition-api.uvue | 474 +++++++++++------- 24 files changed, 851 insertions(+), 684 deletions(-) diff --git a/pages/composition-api/basic/define-emits/array-literal.uvue b/pages/composition-api/basic/define-emits/array-literal.uvue index 9503747..357563a 100644 --- a/pages/composition-api/basic/define-emits/array-literal.uvue +++ b/pages/composition-api/basic/define-emits/array-literal.uvue @@ -1,7 +1,7 @@ diff --git a/pages/composition-api/basic/define-emits/define-emits.test.js b/pages/composition-api/basic/define-emits/define-emits.test.js index 8499c35..e8883f1 100644 --- a/pages/composition-api/basic/define-emits/define-emits.test.js +++ b/pages/composition-api/basic/define-emits/define-emits.test.js @@ -1,40 +1,37 @@ const PAGE_PATH = '/pages/composition-api/basic/define-emits/define-emits' describe('defineEmits', () => { - 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 handleArrayLiteralChangeRes = await page.$('#handle-array-literal-change-res') - expect(await handleArrayLiteralChangeRes.text()).toBe('handle array literal comp change result: ') - - const arrayLiteralEmitBtn = await page.$('#array-literal-emit-btn') - await arrayLiteralEmitBtn.tap() - - expect(await handleArrayLiteralChangeRes.text()).toBe('handle array literal comp change result: options is 1') - - const handleTypeEmits1ChangeRes = await page.$('#handle-type-emits1-change-res') - expect(await handleTypeEmits1ChangeRes.text()).toBe('handle type emits comp change result: ') - - const typeEmits1EmitBtn = await page.$('#type-emits1-emit-btn') - await typeEmits1EmitBtn.tap() - - expect(await handleTypeEmits1ChangeRes.text()).toBe('handle type emits comp change result: options is 2') - - const handleTypeEmits2ChangeRes = await page.$('#handle-type-emits2-change-res') - expect(await handleTypeEmits2ChangeRes.text()).toBe('handle type emits named tuple syntax comp change result: ') - - const typeEmits2EmitBtn = await page.$('#type-emits2-emit-btn') - await typeEmits2EmitBtn.tap() - - expect(await handleTypeEmits2ChangeRes.text()).toBe('handle type emits named tuple syntax comp change result: options is 3') - }) - } else { - it('other platform', () => { - expect(1).toBe(1) - }) - } + let page = null + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const handleArrayLiteralChangeRes = await page.$('#handle-array-literal-change-res') + expect((await handleArrayLiteralChangeRes.text()).trim()).toBe('handle array literal comp change result:') + + const arrayLiteralEmitBtn = await page.$('.array-literal-emit-btn') + await arrayLiteralEmitBtn.tap() + + expect(await handleArrayLiteralChangeRes.text()).toBe( + 'handle array literal comp change result: options is 1') + + const handleTypeEmits1ChangeRes = await page.$('#handle-type-emits1-change-res') + expect((await handleTypeEmits1ChangeRes.text()).trim()).toBe('handle type emits comp change result:') + + const typeEmits1EmitBtn = await page.$('.type-emits1-emit-btn') + await typeEmits1EmitBtn.tap() + + expect(await handleTypeEmits1ChangeRes.text()).toBe('handle type emits comp change result: options is 2') + + const handleTypeEmits2ChangeRes = await page.$('#handle-type-emits2-change-res') + expect((await handleTypeEmits2ChangeRes.text()).trim()).toBe( + 'handle type emits named tuple syntax comp change result:') + + const typeEmits2EmitBtn = await page.$('.type-emits2-emit-btn') + await typeEmits2EmitBtn.tap() + + expect(await handleTypeEmits2ChangeRes.text()).toBe( + 'handle type emits named tuple syntax comp change result: options is 3') + }) }) \ No newline at end of file diff --git a/pages/composition-api/basic/define-emits/type-emits-1.uvue b/pages/composition-api/basic/define-emits/type-emits-1.uvue index 651c604..ac937d8 100644 --- a/pages/composition-api/basic/define-emits/type-emits-1.uvue +++ b/pages/composition-api/basic/define-emits/type-emits-1.uvue @@ -1,7 +1,7 @@ diff --git a/pages/composition-api/basic/define-emits/type-emits-2.uvue b/pages/composition-api/basic/define-emits/type-emits-2.uvue index 4f3589f..3e05199 100644 --- a/pages/composition-api/basic/define-emits/type-emits-2.uvue +++ b/pages/composition-api/basic/define-emits/type-emits-2.uvue @@ -1,7 +1,7 @@ diff --git a/pages/composition-api/basic/define-options/define-options.test.js b/pages/composition-api/basic/define-options/define-options.test.js index 794d1ec..05f0ebd 100644 --- a/pages/composition-api/basic/define-options/define-options.test.js +++ b/pages/composition-api/basic/define-options/define-options.test.js @@ -1,31 +1,25 @@ const PAGE_PATH = '/pages/composition-api/basic/define-options/define-options' describe('defineOptions', () => { - 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 count = await page.$('#count') - expect(await count.text()).toBe('count: 0') - const doubleCount = await page.$('#double-count') - expect(await doubleCount.text()).toBe('double count: 0') - const total = await page.$('#total') - expect(await total.text()).toBe('total: 0') - - const incrementBtn = await page.$('#increment-btn') - await incrementBtn.tap() - - expect(await count.text()).toBe('count: 1') - expect(await doubleCount.text()).toBe('double count: 2') - const price = await page.data('price') - expect(await total.text()).toBe(`total: ${1*price}`) - }) - } else { - it('other platform', () => { - expect(1).toBe(1) - }) - } + let page = null + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const count = await page.$('#count') + expect(await count.text()).toBe('count: 0') + const doubleCount = await page.$('#double-count') + expect(await doubleCount.text()).toBe('double count: 0') + const total = await page.$('#total') + expect(await total.text()).toBe('total: 0') + + const incrementBtn = await page.$('.increment-btn') + await incrementBtn.tap() + + expect(await count.text()).toBe('count: 1') + expect(await doubleCount.text()).toBe('double count: 2') + const price = await page.data('price') + expect(await total.text()).toBe(`total: ${1*price}`) + }) }) \ No newline at end of file diff --git a/pages/composition-api/basic/define-options/define-options.uvue b/pages/composition-api/basic/define-options/define-options.uvue index 7baf8a2..ce14c36 100644 --- a/pages/composition-api/basic/define-options/define-options.uvue +++ b/pages/composition-api/basic/define-options/define-options.uvue @@ -3,7 +3,7 @@ count: {{ count }} double count: {{ doubleCount}} total: {{ total}} - + diff --git a/pages/composition-api/basic/define-props/define-props.test.js b/pages/composition-api/basic/define-props/define-props.test.js index e375515..49abf5b 100644 --- a/pages/composition-api/basic/define-props/define-props.test.js +++ b/pages/composition-api/basic/define-props/define-props.test.js @@ -1,55 +1,71 @@ const PAGE_PATH = '/pages/composition-api/basic/define-props/define-props' describe('defineProps', () => { - 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 arrayLiteralStr = await page.$('#array-literal-str') - expect(await arrayLiteralStr.text()).toBe('str: default str') - const arrayLiteralNum = await page.$('#array-literal-num') - expect(await arrayLiteralNum.text()).toBe('num: 0') - const arrayLiteralBool = await page.$('#array-literal-bool') - expect(await arrayLiteralBool.text()).toBe('bool: false') - const arrayLiteralArr = await page.$('#array-literal-arr') - expect(await arrayLiteralArr.text()).toBe('arr: ["a","b","c"]') - const arrayLiteralObj = await page.$('#array-literal-obj') + let page = null + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const arrayLiteralStr = await page.$('#array-literal-str') + expect(await arrayLiteralStr.text()).toBe('str: default str') + const arrayLiteralNum = await page.$('#array-literal-num') + expect(await arrayLiteralNum.text()).toBe('num: 0') + const arrayLiteralBool = await page.$('#array-literal-bool') + expect(await arrayLiteralBool.text()).toBe('bool: false') + const arrayLiteralArr = await page.$('#array-literal-arr') + expect((await arrayLiteralArr.text()).replaceAll('\n', '')).toBe('arr: ["a","b","c"]') + + const arrayLiteralObj = await page.$('#array-literal-obj') + if (process.env.uniTestPlatformInfo.startsWith('android')) { expect(await arrayLiteralObj.text()).toBe('obj: {"arr":[1,2,3],"num":0,"str":"obj str"}') - const arrayLiteralFn = await page.$('#array-literal-fn') - expect(await arrayLiteralFn.text()).toBe('fn: fn res') + } + if (process.env.uniTestPlatformInfo.startsWith('web')) { + expect((await arrayLiteralObj.text()).replaceAll('\n', '')).toBe( + 'obj: {"str": "obj str","num": 0,"arr": [1,2,3]}') + } - const objectLiteralStr = await page.$('#object-literal-str') - expect(await objectLiteralStr.text()).toBe('str: default str') - const objectLiteralNum = await page.$('#object-literal-num') - expect(await objectLiteralNum.text()).toBe('num: 0') - const objectLiteralBool = await page.$('#object-literal-bool') - expect(await objectLiteralBool.text()).toBe('bool: false') - const objectLiteralArr = await page.$('#object-literal-arr') - expect(await objectLiteralArr.text()).toBe('arr: ["a","b","c"]') - const objectLiteralObj = await page.$('#object-literal-obj') + const arrayLiteralFn = await page.$('#array-literal-fn') + expect(await arrayLiteralFn.text()).toBe('fn: fn res') + + const objectLiteralStr = await page.$('#object-literal-str') + expect(await objectLiteralStr.text()).toBe('str: default str') + const objectLiteralNum = await page.$('#object-literal-num') + expect(await objectLiteralNum.text()).toBe('num: 0') + const objectLiteralBool = await page.$('#object-literal-bool') + expect(await objectLiteralBool.text()).toBe('bool: false') + const objectLiteralArr = await page.$('#object-literal-arr') + expect((await objectLiteralArr.text()).replaceAll('\n', '')).toBe('arr: ["a","b","c"]') + + const objectLiteralObj = await page.$('#object-literal-obj') + if (process.env.uniTestPlatformInfo.startsWith('android')) { expect(await objectLiteralObj.text()).toBe('obj: {"a":1}') - const objectLiteralFn = await page.$('#object-literal-fn') - expect(await objectLiteralFn.text()).toBe('fn: fn res') + } + if (process.env.uniTestPlatformInfo.startsWith('web')) { + expect((await objectLiteralObj.text()).replaceAll('\n', '')).toBe('obj: {"a": 1}') + } + + const objectLiteralFn = await page.$('#object-literal-fn') + expect(await objectLiteralFn.text()).toBe('fn: fn res') - const typeStr = await page.$('#type-str') - expect(await typeStr.text()).toBe('str: default str') - const typeNum = await page.$('#type-num') - expect(await typeNum.text()).toBe('num: 0') - const typeBool = await page.$('#type-bool') - expect(await typeBool.text()).toBe('bool: false') - const typeArr = await page.$('#type-arr') - expect(await typeArr.text()).toBe('arr: ["a","b","c"]') - const typeObj = await page.$('#type-obj') + const typeStr = await page.$('#type-str') + expect(await typeStr.text()).toBe('str: default str') + const typeNum = await page.$('#type-num') + expect(await typeNum.text()).toBe('num: 0') + const typeBool = await page.$('#type-bool') + expect(await typeBool.text()).toBe('bool: false') + const typeArr = await page.$('#type-arr') + expect((await typeArr.text()).replaceAll('\n', '')).toBe('arr: ["a","b","c"]') + + const typeObj = await page.$('#type-obj') + if (process.env.uniTestPlatformInfo.startsWith('android')) { expect(await typeObj.text()).toBe('obj: {"arr":[1,2,3],"num":0,"str":"obj str"}') - const typeFn = await page.$('#type-fn') - expect(await typeFn.text()).toBe('fn: fn res') - }) - } else { - it('other platform', () => { - expect(1).toBe(1) - }) - } + } + if (process.env.uniTestPlatformInfo.startsWith('web')) { + expect((await typeObj.text()).replaceAll('\n', '')).toBe('obj: {"str": "obj str","num": 0,"arr": [1,2,3]}') + + } + const typeFn = await page.$('#type-fn') + expect(await typeFn.text()).toBe('fn: fn res') + }) }) \ No newline at end of file diff --git a/pages/composition-api/basic/define-slots/define-slots.test.js b/pages/composition-api/basic/define-slots/define-slots.test.js index 427deb3..e87c039 100644 --- a/pages/composition-api/basic/define-slots/define-slots.test.js +++ b/pages/composition-api/basic/define-slots/define-slots.test.js @@ -1,25 +1,19 @@ const PAGE_PATH = '/pages/composition-api/basic/define-slots/define-slots' describe('defineSlots', () => { - 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 slotHeader = await page.$('#slot-header') - expect(await slotHeader.text()).toBe('header slot msg: foo msg') - - const slotContent = await page.$('#slot-default') - expect(await slotContent.text()).toBe('default slot num: 0') - - const slotFooter = await page.$('#slot-footer') - expect(await slotFooter.text()).toBe('footer slot arr: ["a","b","c"]') - }) - } else { - it('other platform', () => { - expect(1).toBe(1) - }) - } + let page = null + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const slotHeader = await page.$('#slot-header') + expect(await slotHeader.text()).toBe('header slot msg: foo msg') + + const slotContent = await page.$('#slot-default') + expect(await slotContent.text()).toBe('default slot num: 0') + + const slotFooter = await page.$('#slot-footer') + expect((await slotFooter.text()).replaceAll('\n', '')).toBe('footer slot arr: ["a","b","c"]') + }) }) \ No newline at end of file diff --git a/pages/composition-api/basic/use-attrs/use-attrs.test.js b/pages/composition-api/basic/use-attrs/use-attrs.test.js index 4b2575e..6f0c853 100644 --- a/pages/composition-api/basic/use-attrs/use-attrs.test.js +++ b/pages/composition-api/basic/use-attrs/use-attrs.test.js @@ -1,22 +1,17 @@ const PAGE_PATH = '/pages/composition-api/basic/use-attrs/use-attrs' describe('useAttrs', () => { - 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 attrsClass = await page.$('#attrs-class') - expect(await attrsClass.text()).toBe('attrs.class: foo') + let page = null + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const attrsClass = await page.$('#attrs-class') + expect(await attrsClass.text()).toBe('attrs.class: foo') + + const attrsMsg = await page.$('#attrs-msg') + expect(await attrsMsg.text()).toBe('attrs.msg: msg') + }) - const attrsMsg = await page.$('#attrs-msg') - expect(await attrsMsg.text()).toBe('attrs.msg: msg') - }) - } else { - it('other platform', () => { - expect(1).toBe(1) - }) - } }) \ No newline at end of file diff --git a/pages/composition-api/reactivity/computed/computed.test.js b/pages/composition-api/reactivity/computed/computed.test.js index 49873d5..90a7e4f 100644 --- a/pages/composition-api/reactivity/computed/computed.test.js +++ b/pages/composition-api/reactivity/computed/computed.test.js @@ -1,34 +1,29 @@ const PAGE_PATH = '/pages/composition-api/reactivity/computed/computed' describe('computed', () => { - 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 count = await page.$('#count') - expect(await count.text()).toBe('count: 0') - const doubleCount = await page.$('#double-count') - expect(await doubleCount.text()).toBe('computed double count: 0') + let page = null + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const count = await page.$('#count') + expect(await count.text()).toBe('count: 0') + const doubleCount = await page.$('#double-count') + expect(await doubleCount.text()).toBe('computed double count: 0') - const objArr = await page.$('#obj-arr') - expect(await objArr.text()).toBe('obj.arr: [1,2,3]') - const objArrLen = await page.$('#obj-arr-len') - expect(await objArrLen.text()).toBe('computed obj.arr.length: 3') + const objArr = await page.$('#obj-arr') + expect((await objArr.text()).replaceAll('\n', '')).toBe('obj.arr: [1,2,3]') + const objArrLen = await page.$('#obj-arr-len') + expect(await objArrLen.text()).toBe('computed obj.arr.length: 3') - const updateBtn = await page.$('#update-btn') - await updateBtn.tap() + const updateBtn = await page.$('.update-btn') + await updateBtn.tap() + + expect(await count.text()).toBe('count: 1') + expect(await doubleCount.text()).toBe('computed double count: 2') + expect((await objArr.text()).replaceAll('\n', '')).toBe('obj.arr: [1,2,3,4]') + expect(await objArrLen.text()).toBe('computed obj.arr.length: 4') + }) - expect(await count.text()).toBe('count: 1') - expect(await doubleCount.text()).toBe('computed double count: 2') - expect(await objArr.text()).toBe('obj.arr: [1,2,3,4]') - expect(await objArrLen.text()).toBe('computed obj.arr.length: 4') - }) - } else { - it('other platform', () => { - expect(1).toBe(1) - }) - } }) \ No newline at end of file diff --git a/pages/composition-api/reactivity/computed/computed.uvue b/pages/composition-api/reactivity/computed/computed.uvue index 2ec5d0f..bf59641 100644 --- a/pages/composition-api/reactivity/computed/computed.uvue +++ b/pages/composition-api/reactivity/computed/computed.uvue @@ -4,7 +4,7 @@ computed double count: {{ doubleCount }} obj.arr: {{ obj.arr }} computed obj.arr.length: {{ objArrLen }} - + diff --git a/pages/composition-api/reactivity/is-ref/is-ref.test.js b/pages/composition-api/reactivity/is-ref/is-ref.test.js index a36b71f..adf6266 100644 --- a/pages/composition-api/reactivity/is-ref/is-ref.test.js +++ b/pages/composition-api/reactivity/is-ref/is-ref.test.js @@ -1,26 +1,20 @@ const PAGE_PATH = '/pages/composition-api/reactivity/is-ref/is-ref' describe('isRef', () => { - 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') - }) - } else { - it('other platform', () => { - expect(1).toBe(1) - }) - } + 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') + }) }) \ No newline at end of file diff --git a/pages/composition-api/reactivity/ref/ref.test.js b/pages/composition-api/reactivity/ref/ref.test.js index d21563a..7d5603f 100644 --- a/pages/composition-api/reactivity/ref/ref.test.js +++ b/pages/composition-api/reactivity/ref/ref.test.js @@ -1,30 +1,25 @@ const PAGE_PATH = '/pages/composition-api/reactivity/ref/ref' describe('ref', () => { - 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 count1 = await page.$('#count1') - expect(await count1.text()).toBe('count1: 0') - const count2 = await page.$('#count2') - expect(await count2.text()).toBe('count2: 0') - const counterCount = await page.$('#counter-count') - expect(await counterCount.text()).toBe('counter.count: 0') + let page = null + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const count1 = await page.$('#count1') + expect(await count1.text()).toBe('count1: 0') + const count2 = await page.$('#count2') + expect(await count2.text()).toBe('count2: 0') + const counterCount = await page.$('#counter-count') + expect(await counterCount.text()).toBe('counter.count: 0') - const incrementBtn = await page.$('#increment-btn') - await incrementBtn.tap() + const incrementBtn = await page.$('.increment-btn') + await incrementBtn.tap() + + expect(await count1.text()).toBe('count1: 2') + expect(await count2.text()).toBe('count2: 2') + expect(await counterCount.text()).toBe('counter.count: 1') + }) - expect(await count1.text()).toBe('count1: 2') - expect(await count2.text()).toBe('count2: 2') - expect(await counterCount.text()).toBe('counter.count: 1') - }) - } else { - it('other platform', () => { - expect(1).toBe(1) - }) - } }) \ No newline at end of file diff --git a/pages/composition-api/reactivity/ref/ref.uvue b/pages/composition-api/reactivity/ref/ref.uvue index 25dc5ed..bc73789 100644 --- a/pages/composition-api/reactivity/ref/ref.uvue +++ b/pages/composition-api/reactivity/ref/ref.uvue @@ -3,7 +3,7 @@ count1: {{ count1 }} count2: {{ count2 }} counter.count: {{ counter.count }} - + diff --git a/pages/composition-api/reactivity/shallow-reactive/shallow-reactive.test.js b/pages/composition-api/reactivity/shallow-reactive/shallow-reactive.test.js index 8691dcb..a5385c3 100644 --- a/pages/composition-api/reactivity/shallow-reactive/shallow-reactive.test.js +++ b/pages/composition-api/reactivity/shallow-reactive/shallow-reactive.test.js @@ -1,33 +1,27 @@ const PAGE_PATH = '/pages/composition-api/reactivity/shallow-reactive/shallow-reactive' describe('shallowReactive', () => { - 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 stateCount = await page.$('#state-count') - expect(await stateCount.text()).toBe('state.count: 0') + let page = null + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const stateCount = await page.$('#state-count') + expect(await stateCount.text()).toBe('state.count: 0') - const stateNestedCount = await page.$('#state-nested-count') - expect(await stateNestedCount.text()).toBe('state.nested.count: 0') + const stateNestedCount = await page.$('#state-nested-count') + expect(await stateNestedCount.text()).toBe('state.nested.count: 0') - const incrementStateNestedCountBtn = await page.$('#increment-state-nested-count-btn') - await incrementStateNestedCountBtn.tap() + const incrementStateNestedCountBtn = await page.$('.increment-state-nested-count-btn') + await incrementStateNestedCountBtn.tap() - expect(await stateNestedCount.text()).toBe('state.nested.count: 0') + expect(await stateNestedCount.text()).toBe('state.nested.count: 0') - const incrementStateCountBtn = await page.$('#increment-state-count-btn') - await incrementStateCountBtn.tap() + const incrementStateCountBtn = await page.$('.increment-state-count-btn') + await incrementStateCountBtn.tap() - expect(await stateCount.text()).toBe('state.count: 1') - expect(await stateNestedCount.text()).toBe('state.nested.count: 1') - }) - } else { - it('other platform', () => { - expect(1).toBe(1) - }) - } + expect(await stateCount.text()).toBe('state.count: 1') + expect(await stateNestedCount.text()).toBe('state.nested.count: 1') + }) }) \ No newline at end of file diff --git a/pages/composition-api/reactivity/shallow-reactive/shallow-reactive.uvue b/pages/composition-api/reactivity/shallow-reactive/shallow-reactive.uvue index 578c922..3c983c9 100644 --- a/pages/composition-api/reactivity/shallow-reactive/shallow-reactive.uvue +++ b/pages/composition-api/reactivity/shallow-reactive/shallow-reactive.uvue @@ -1,11 +1,11 @@