diff --git a/pages.json b/pages.json index 03bbfa2e58f3ea89044accdcfa3b0c572bbd0693..3f76e947e0320741936662abc0bc57158eef4bb1 100644 --- a/pages.json +++ b/pages.json @@ -711,9 +711,15 @@ } }, { - "path": "pages/render-function/render/render", + "path": "pages/render-function/render/render-options", "style": { - "navigationBarTitleText": "render function" + "navigationBarTitleText": "render 选项式 API" + } + }, + { + "path": "pages/render-function/render/render-composition", + "style": { + "navigationBarTitleText": "render 组合式 API" } }, { diff --git a/pages/index/index.uvue b/pages/index/index.uvue index c42363c4e30bd726e410013a486379ea890a8ab9..b8d675e6efd01e1d177b82c9ebd6536e805607fa 100644 --- a/pages/index/index.uvue +++ b/pages/index/index.uvue @@ -976,7 +976,18 @@ export default { { id: 'render', name: 'render & h()', - url: 'render/render' + children: [ + { + id: 'render-options', + name: 'render 选项式 API', + url: 'render-options' + }, + { + id: 'render-composition', + name: 'render 组合式 API', + url: 'render-composition' + }, + ] }, { id: 'mergeProps', diff --git a/pages/render-function/render/render-composition.uvue b/pages/render-function/render/render-composition.uvue new file mode 100644 index 0000000000000000000000000000000000000000..5080576667a22dc9dd5f2ccc1daaa7c959c893c6 --- /dev/null +++ b/pages/render-function/render/render-composition.uvue @@ -0,0 +1,36 @@ + + + \ No newline at end of file diff --git a/pages/render-function/render/render.uvue b/pages/render-function/render/render-options.uvue similarity index 100% rename from pages/render-function/render/render.uvue rename to pages/render-function/render/render-options.uvue diff --git a/pages/render-function/render/render.test.js b/pages/render-function/render/render.test.js index 31263ea37ef839e6482f7d0853d4b97dba603763..26ba0597c2beb79b1d8cd82bc3ad5d27ce1e0de9 100644 --- a/pages/render-function/render/render.test.js +++ b/pages/render-function/render/render.test.js @@ -1,35 +1,48 @@ -const PAGE_PATH = '/pages/render-function/render/render' +const OPTIONS_PAGE_PATH = '/pages/render-function/render/render-options' +const COMPOSITION_PAGE_PATH = '/pages/render-function/render/render-composition' -describe('/pages/render-function/render/render', () => { - if (process.env.uniTestPlatformInfo.startsWith('web')) { - // TODO: web 端测试未获取到元素 - it('web', async () => { - expect(1).toBe(1) - }) +describe('render-function render', () => { + const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() + const isWeb = platformInfo.startsWith('web') + const isIos = platformInfo.startsWith('ios') + if (isWeb) { + it("web platform test cannot get render dom", async () => { + expect(1).toBe(1); + }); return } let page - beforeAll(async () => { - page = await program.reLaunch(PAGE_PATH) + const test = async (pagePath) => { + page = await program.reLaunch(pagePath) await page.waitFor('view') - }) - it('component', async () => { + const ComForRenderFunction = await page.$('.component-for-h-function') expect(await ComForRenderFunction.text()).toEqual( 'component for h()' ) const compSlot = await page.$('.comp-slot') expect(await compSlot.text()).toEqual('component slot') - }) - it('text', async () => { - const msgEl = await page.$('.msg') + + let msgEl = await page.$('.msg') expect(await msgEl.text()).toEqual('default msg') - }) - it('button', async () => { + const btnEl = await page.$('.btn') expect(await btnEl.property('type')).toBe('primary') await btnEl.tap() - const msgEl = await page.$('.msg') + msgEl = await page.$('.msg') expect(await msgEl.text()).toEqual('new msg') + } + + it('render options API', async () => { + await test(OPTIONS_PAGE_PATH) + }) + + it('render composition API', async () => { + if (!isIos) { + await test(COMPOSITION_PAGE_PATH) + } else { + // TODO: ios 端 defineOptions + render 页面空白 + expect(1).toBe(1); + } }) }) \ No newline at end of file