diff --git a/pages.json b/pages.json index a5eb2a69f1525e17bee4a63b77b8ec762cd79f11..ec6b851c8424ed54c3163a9b62d3327a4eb0b9f3 100644 --- a/pages.json +++ b/pages.json @@ -369,6 +369,12 @@ "navigationBarTitleText": "inject" } }, + { + "path": "pages/composition/setup/setup", + "style": { + "navigationBarTitleText": "setup" + } + }, { "path": "pages/examples/nested-component-communication/nested-component-communication", "style": { diff --git a/pages/composition/setup/Foo.uvue b/pages/composition/setup/Foo.uvue new file mode 100644 index 0000000000000000000000000000000000000000..f6c4c0826e5dceb9b08afbc0b29c7b3f4c3e5cf7 --- /dev/null +++ b/pages/composition/setup/Foo.uvue @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/pages/composition/setup/RenderFunction.uvue b/pages/composition/setup/RenderFunction.uvue new file mode 100644 index 0000000000000000000000000000000000000000..9f171662ed9235ceabb97493a5b620905bfbcef9 --- /dev/null +++ b/pages/composition/setup/RenderFunction.uvue @@ -0,0 +1,44 @@ + + + \ No newline at end of file diff --git a/pages/composition/setup/setup.test.js b/pages/composition/setup/setup.test.js new file mode 100644 index 0000000000000000000000000000000000000000..7e096d02cabce0f00cc74ad5522420d2f7e2fcf3 --- /dev/null +++ b/pages/composition/setup/setup.test.js @@ -0,0 +1,89 @@ +const PAGE_PATH = '/pages/composition/setup/setup' +describe('options setup', () => { + if (process.env.uniTestPlatformInfo.startsWith('android')) { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const str = await page.$('#str') + expect(await str.text()).toBe('str: default str') + const num = await page.$('#num') + expect(await num.text()).toBe('num: 0') + const bool = await page.$('#bool') + expect(await bool.text()).toBe('bool: false') + + const count = await page.$('#count') + expect(await count.text()).toBe('count: 0') + + const objStr = await page.$('#obj-str') + expect(await objStr.text()).toBe('obj.str: obj default str') + const objNum = await page.$('#obj-num') + expect(await objNum.text()).toBe('obj.num: 0') + const objBool = await page.$('#obj-bool') + expect(await objBool.text()).toBe('obj.bool: false') + + const propsStr = await page.$('#props-str') + expect(await propsStr.text()).toBe('props.str: default str') + const propsCount = await page.$('#props-count') + expect(await propsCount.text()).toBe('props.count: 0') + const propsObjStr = await page.$('#props-obj-str') + expect(await propsObjStr.text()).toBe(`props.obj['str']: obj default str`) + const propsObjNum = await page.$('#props-obj-num') + expect(await propsObjNum.text()).toBe(`props.obj['num']: 0`) + const propsObjBool = await page.$('#props-obj-bool') + expect(await propsObjBool.text()).toBe(`props.obj['bool']: false`) + }) + it('props', async () => { + const incrementBtn = await page.$('#increment-btn') + await incrementBtn.tap() + + const count = await page.$('#count') + expect(await count.text()).toBe('count: 1') + const propsCount = await page.$('#props-count') + expect(await propsCount.text()).toBe('props.count: 1') + + const updateObjBtn = await page.$('#update-obj-btn') + await updateObjBtn.tap() + + const objStr = await page.$('#obj-str') + expect(await objStr.text()).toBe('obj.str: obj new str') + const objNum = await page.$('#obj-num') + expect(await objNum.text()).toBe('obj.num: 100') + const objBool = await page.$('#obj-bool') + expect(await objBool.text()).toBe('obj.bool: true') + + const propsObjStr = await page.$('#props-obj-str') + expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str`) + const propsObjNum = await page.$('#props-obj-num') + expect(await propsObjNum.text()).toBe(`props.obj['num']: 100`) + const propsObjBool = await page.$('#props-obj-bool') + expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`) + }) + it('context', async () => { + // attrs + const contextAttrsIsShow = await page.$('#context-attrs-is-show') + expect(await contextAttrsIsShow.text()).toBe('context.attrs.isShow: true') + // emits + const compUpdateObjBtn = await page.$('#comp-update-obj-btn') + await compUpdateObjBtn.tap() + const propsObjStr = await page.$('#props-obj-str') + expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str by comp update`) + const propsObjNum = await page.$('#props-obj-num') + expect(await propsObjNum.text()).toBe(`props.obj['num']: 200`) + const propsObjBool = await page.$('#props-obj-bool') + expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`) + // slots + const defaultSlotInFoo = await page.$('#default-slot-in-foo') + expect(await defaultSlotInFoo.text()).toBe('default slot in Foo') + const hasDefaultSlot = await page.$('#has-default-slot') + expect(await hasDefaultSlot.text()).toBe('hasDefaultSlot: true') + }) + } else { + // TODO: web 端暂不支持 + it('web', async () => { + expect(1).toBe(1) + }) + } +}) \ No newline at end of file diff --git a/pages/composition/setup/setup.uvue b/pages/composition/setup/setup.uvue new file mode 100644 index 0000000000000000000000000000000000000000..c5c9989c25760d55d11b3e063fcf5a6fc2a5b12a --- /dev/null +++ b/pages/composition/setup/setup.uvue @@ -0,0 +1,64 @@ + + + diff --git a/pages/index.uvue b/pages/index.uvue index d31b27b1172b9047d25808d4b34c7aeffcdec8a7..5cec8050015d00d52a04c8acbb55d980d26ad773 100644 --- a/pages/index.uvue +++ b/pages/index.uvue @@ -429,7 +429,12 @@ name: 'extends', url: 'extends', enable: false, - } + }, + { + name: 'setup', + url: 'setup', + enable: true, + } ] as PageItem[], }, {