提交 dce25de4 编写于 作者: 雪洛's avatar 雪洛

feat: 开放部分web端测试例

上级 a0b13400
...@@ -9,13 +9,11 @@ import GlobalChildMixinComp2 from '@/pages/composition/mixins/components/GlobalC ...@@ -9,13 +9,11 @@ import GlobalChildMixinComp2 from '@/pages/composition/mixins/components/GlobalC
import MixinCompForGlobalMixin from '@/pages/composition/mixins/components/MixinCompForGlobalMixin.uvue' import MixinCompForGlobalMixin from '@/pages/composition/mixins/components/MixinCompForGlobalMixin.uvue'
import MixinCompForGlobalChildMixin from '@/pages/composition/mixins/components/MixinCompForGlobalChildMixin.uvue' import MixinCompForGlobalChildMixin from '@/pages/composition/mixins/components/MixinCompForGlobalChildMixin.uvue'
// #ifdef APP-ANDROID
import plugin1 from '@/plugins/plugin1.uts' import plugin1 from '@/plugins/plugin1.uts'
import plugin2 from '@/plugins/plugin2.uts' import plugin2 from '@/plugins/plugin2.uts'
import plugin3 from '@/plugins/plugin3.uts' import plugin3 from '@/plugins/plugin3.uts'
import plugin4 from '@/plugins/plugin4.uts' import plugin4 from '@/plugins/plugin4.uts'
import CompForPlugin from '@/components/CompForPlugin.uvue' import CompForPlugin from '@/components/CompForPlugin.uvue'
// #endif
export function createApp() { export function createApp() {
const app = createSSRApp(App) const app = createSSRApp(App)
...@@ -266,7 +264,6 @@ export function createApp() { ...@@ -266,7 +264,6 @@ export function createApp() {
app.mixin(globalMixin) app.mixin(globalMixin)
// #endif // #endif
// #ifdef APP-ANDROID
app.use(plugin1) app.use(plugin1)
app.use(plugin2) app.use(plugin2)
app.use(plugin3) app.use(plugin3)
...@@ -274,7 +271,6 @@ export function createApp() { ...@@ -274,7 +271,6 @@ export function createApp() {
app.use(function (app: VueApp, componentName: string, componentInstance: CreateVueComponent) { app.use(function (app: VueApp, componentName: string, componentInstance: CreateVueComponent) {
app.component(componentName, componentInstance) app.component(componentName, componentInstance)
}, 'CompForPlugin', CompForPlugin) }, 'CompForPlugin', CompForPlugin)
// #endif
app.config.globalProperties.globalPropertiesStr = 'default string' app.config.globalProperties.globalPropertiesStr = 'default string'
app.config.globalProperties.globalPropertiesNum = 0 app.config.globalProperties.globalPropertiesNum = 0
......
...@@ -12,30 +12,28 @@ describe('app-instance', () => { ...@@ -12,30 +12,28 @@ describe('app-instance', () => {
expect(CompForAppComponentText).toBe('component for app.component') expect(CompForAppComponentText).toBe('component for app.component')
}) })
it('app.use', async () => { it('app.use', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { const plugin1El = await page.$('.plugin1')
const plugin1El = await page.$('.plugin1') const plugin1Text = await plugin1El.text()
const plugin1Text = await plugin1El.text() expect(plugin1Text).toBe('plugin1: 通过字面量方式创建的 plugin')
expect(plugin1Text).toBe('plugin1: 通过字面量方式创建的 plugin')
const plugin2El = await page.$('.plugin2') const plugin2El = await page.$('.plugin2')
const plugin2Text = await plugin2El.text() const plugin2Text = await plugin2El.text()
expect(plugin2Text).toBe('plugin2: 通过函数方式创建的 plugin') expect(plugin2Text).toBe('plugin2: 通过函数方式创建的 plugin')
const plugin3El = await page.$('.plugin3') const plugin3El = await page.$('.plugin3')
const plugin3Text = await plugin3El.text() const plugin3Text = await plugin3El.text()
expect(plugin3Text).toBe( expect(plugin3Text).toBe(
'plugin3: 通过 definePlugin + 对象字面量方式创建的 plugin' 'plugin3: 通过 definePlugin + 对象字面量方式创建的 plugin'
) )
const plugin4El = await page.$('.plugin4') const plugin4El = await page.$('.plugin4')
const plugin4Text = await plugin4El.text() const plugin4Text = await plugin4El.text()
expect(plugin4Text).toBe( expect(plugin4Text).toBe(
'plugin4: 通过 definePlugin + 函数方式创建的 plugin' 'plugin4: 通过 definePlugin + 函数方式创建的 plugin'
) )
const compForPluginEl = await page.$('.component-for-plugin') const compForPluginEl = await page.$('.component-for-plugin')
const compForPluginText = await compForPluginEl.text() const compForPluginText = await compForPluginEl.text()
expect(compForPluginText).toBe('component for plugin') expect(compForPluginText).toBe('component for plugin')
}
}) })
}) })
<template> <template>
<view class="page"> <view class="page">
<CompForAppComponent class="component-for-app-component" /> <CompForAppComponent class="component-for-app-component" />
// #ifdef APP-ANDROID
<CompForAppUse class="component-for-app-use" /> <CompForAppUse class="component-for-app-use" />
// #endif
</view> </view>
</template> </template>
<script lang="uts"> <script lang="uts">
import { state} from '@/store/index.uts' import { state} from '@/store/index.uts'
import CompForAppComponent from '@/components/CompForAppComponent.uvue' import CompForAppComponent from '@/components/CompForAppComponent.uvue'
// #ifdef APP-ANDROID
import CompForAppUse from '@/components/CompForAppUse.uvue' import CompForAppUse from '@/components/CompForAppUse.uvue'
// #endif
export default { export default {
components: { components: {
CompForAppComponent, CompForAppComponent,
// #ifdef APP-ANDROID
CompForAppUse CompForAppUse
// #endif
}, },
methods: { methods: {
// 自动化测试 // 自动化测试
......
const PAGE_PATH = '/pages/component-instance/force-update/force-update' const PAGE_PATH = '/pages/component-instance/force-update/force-update'
describe('$forceUpdate', () => { describe('$forceUpdate', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page
let page beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const timeEl = await page.$('.time')
const timeEl = await page.$('.time') const timeText1 = (await timeEl.text()).replace('Date.now(): ', '')
const timeText1 = (await timeEl.text()).replace('Date.now(): ', '')
const triggerForceUpdateBtn = await page.$('.trigger-force-update-btn') const triggerForceUpdateBtn = await page.$('.trigger-force-update-btn')
await triggerForceUpdateBtn.tap() await triggerForceUpdateBtn.tap()
const timeText2 = (await timeEl.text()).replace('Date.now(): ', '') const timeText2 = (await timeEl.text()).replace('Date.now(): ', '')
expect(parseInt(timeText2)).toBeGreaterThan(parseInt(timeText1)) expect(parseInt(timeText2)).toBeGreaterThan(parseInt(timeText1))
}) })
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
}) })
...@@ -19,11 +19,7 @@ export default { ...@@ -19,11 +19,7 @@ export default {
}, },
methods: { methods: {
testFunction () { testFunction () {
// #ifdef UNI-APP-X && APP-ANDROID
this.callbackValue = this.$parent!.$callMethod('testFunction') as string this.callbackValue = this.$parent!.$callMethod('testFunction') as string
// #endif
// TODO: 非 app-android 简单绕过, web 无法通过 this.$parent.functionName 调用父组件 methods 中的方法
this.callbackValue = 'parentFunctionResult'
} }
} }
} }
......
const PAGE_PATH = '/pages/composition-api/basic/define-expose/define-expose' const PAGE_PATH = '/pages/composition-api/basic/define-expose/define-expose'
describe('defineExpose', () => { describe('defineExpose', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const fooStr = await page.$('#foo-str')
const fooStr = await page.$('#foo-str') expect(await fooStr.text()).toBe('str from component Foo: foo str')
expect(await fooStr.text()).toBe('str from component Foo: foo str') const fooNum = await page.$('#foo-num')
const fooNum = await page.$('#foo-num') expect(await fooNum.text()).toBe('num from component Foo: 0')
expect(await fooNum.text()).toBe('num from component Foo: 0')
const incrementBtn = await page.$('#increment-btn')
const incrementBtn = await page.$('#increment-btn') await incrementBtn.tap()
await incrementBtn.tap()
expect(await fooNum.text()).toBe('num from component Foo: 1')
expect(await fooNum.text()).toBe('num from component Foo: 1') })
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/basic/define-model/define-model' const PAGE_PATH = '/pages/composition-api/basic/define-model/define-model'
describe('defineModel', () => { describe('defineModel', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const modelValueText = await page.$('#model-value-text')
const modelValueText = await page.$('#model-value-text') expect(await modelValueText.text()).toBe('modelValue in Foo: str')
expect(await modelValueText.text()).toBe('modelValue in Foo: str')
const modelValueInput = await page.$('#model-value-input') const modelValueInput = await page.$('#model-value-input')
expect(await modelValueInput.property('value')).toBe('str') expect(await modelValueInput.property('value')).toBe('str')
const msgText = await page.$('#msg-text') const msgText = await page.$('#msg-text')
expect(await msgText.text()).toBe('msg in Foo: msg') expect(await msgText.text()).toBe('msg in Foo: msg')
const msgInput = await page.$('#msg-input') const msgInput = await page.$('#msg-input')
expect(await msgInput.property('value')).toBe('msg') expect(await msgInput.property('value')).toBe('msg')
const updateValueBtn = await page.$('#update-value-btn') const updateValueBtn = await page.$('#update-value-btn')
await updateValueBtn.tap() await updateValueBtn.tap()
expect(await modelValueText.text()).toBe('modelValue in Foo: str1') expect(await modelValueText.text()).toBe('modelValue in Foo: str1')
expect(await modelValueInput.property('value')).toBe('str1') expect(await modelValueInput.property('value')).toBe('str1')
expect(await msgText.text()).toBe('msg in Foo: msg2') expect(await msgText.text()).toBe('msg in Foo: msg2')
expect(await msgInput.property('value')).toBe('msg2') expect(await msgInput.property('value')).toBe('msg2')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/basic/use-slots/use-slots' const PAGE_PATH = '/pages/composition-api/basic/use-slots/use-slots'
describe('useSlots', () => { describe('useSlots', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const slotHeader = await page.$('#slot-header')
const slotHeader = await page.$('#slot-header') expect(await slotHeader.text()).toBe('header slot num: 0')
expect(await slotHeader.text()).toBe('header slot num: 0')
const slotContent = await page.$('#slot-default')
const slotContent = await page.$('#slot-default') expect(await slotContent.text()).toBe('default slot msg: default msg')
expect(await slotContent.text()).toBe('default slot msg: default msg')
const slotFooter = await page.$('#slot-footer')
const slotFooter = await page.$('#slot-footer') expect(await slotFooter.text()).toBe('footer slot arr: ["a","b","c"]')
expect(await slotFooter.text()).toBe('footer slot arr: ["a","b","c"]')
const checkUseSlotsRes = await page.$('#check-use-slots-res')
const checkUseSlotsRes = await page.$('#check-use-slots-res') expect(await checkUseSlotsRes.text()).toBe('check useSlots result: false')
expect(await checkUseSlotsRes.text()).toBe('check useSlots result: false')
const checkUseSlotsBtn = await page.$('#check-use-slots-btn')
const checkUseSlotsBtn = await page.$('#check-use-slots-btn') await checkUseSlotsBtn.tap()
await checkUseSlotsBtn.tap()
expect(await checkUseSlotsRes.text()).toBe('check useSlots result: true')
expect(await checkUseSlotsRes.text()).toBe('check useSlots result: true') })
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/custom-ref/custom-ref' const PAGE_PATH = '/pages/composition-api/reactivity/custom-ref/custom-ref'
describe('customRef', () => { describe('customRef', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const stateCount = await page.$('#state-count')
const stateCount = await page.$('#state-count') expect(await stateCount.text()).toBe('state.count: 0')
expect(await stateCount.text()).toBe('state.count: 0')
const incrementBtn = await page.$('#increment-btn') const incrementBtn = await page.$('#increment-btn')
await incrementBtn.tap() await incrementBtn.tap()
expect(await stateCount.text()).toBe('state.count: 0') expect(await stateCount.text()).toBe('state.count: 0')
const triggerRefBtn = await page.$('#trigger-ref-btn') const triggerRefBtn = await page.$('#trigger-ref-btn')
await triggerRefBtn.tap() await triggerRefBtn.tap()
expect(await stateCount.text()).toBe('state.count: 1') expect(await stateCount.text()).toBe('state.count: 1')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/effect-scope/effect-scope' const PAGE_PATH = '/pages/composition-api/reactivity/effect-scope/effect-scope'
describe('effectScope', () => { describe('effectScope', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const counter = await page.$('#counter')
const counter = await page.$('#counter') expect(await counter.text()).toBe('counter: 0')
expect(await counter.text()).toBe('counter: 0')
const watchCounterRes = await page.$('#watch-counter-res')
const watchCounterRes = await page.$('#watch-counter-res') expect(await watchCounterRes.text()).toBe('watch counter result: ')
expect(await watchCounterRes.text()).toBe('watch counter result: ')
const watchEffectCounterRes = await page.$('#watch-effect-counter-res')
const watchEffectCounterRes = await page.$('#watch-effect-counter-res') expect(await watchEffectCounterRes.text()).toBe('watchEffect counter result: counter: 0')
expect(await watchEffectCounterRes.text()).toBe('watchEffect counter result: counter: 0')
const incrementCounterBtn = await page.$('#increment-counter-btn')
const incrementCounterBtn = await page.$('#increment-counter-btn') await incrementCounterBtn.tap()
await incrementCounterBtn.tap()
expect(await counter.text()).toBe('counter: 1')
expect(await counter.text()).toBe('counter: 1') expect(await watchCounterRes.text()).toBe('watch counter result: newVal: 1, oldVal: 0')
expect(await watchCounterRes.text()).toBe('watch counter result: newVal: 1, oldVal: 0') expect(await watchEffectCounterRes.text()).toBe('watchEffect counter result: counter: 1')
expect(await watchEffectCounterRes.text()).toBe('watchEffect counter result: counter: 1')
const stopEffectScopeBtn = await page.$('#stop-effect-scope-btn')
const stopEffectScopeBtn = await page.$('#stop-effect-scope-btn') await stopEffectScopeBtn.tap()
await stopEffectScopeBtn.tap()
await incrementCounterBtn.tap()
await incrementCounterBtn.tap()
expect(await counter.text()).toBe('counter: 2')
expect(await counter.text()).toBe('counter: 2') expect(await watchCounterRes.text()).toBe('watch counter result: newVal: 1, oldVal: 0')
expect(await watchCounterRes.text()).toBe('watch counter result: newVal: 1, oldVal: 0') expect(await watchEffectCounterRes.text()).toBe('watchEffect counter result: counter: 1')
expect(await watchEffectCounterRes.text()).toBe('watchEffect counter result: counter: 1')
})
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/get-current-scope/get-current-scope' const PAGE_PATH = '/pages/composition-api/reactivity/get-current-scope/get-current-scope'
describe('getCurrentScope', () => { describe('getCurrentScope', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const hasCurrentScope = await page.$('#has-current-scope')
const hasCurrentScope = await page.$('#has-current-scope') expect(await hasCurrentScope.text()).toBe('hasCurrentScope: false')
expect(await hasCurrentScope.text()).toBe('hasCurrentScope: false')
const createScopeBtn = await page.$('#create-scope-btn')
const createScopeBtn = await page.$('#create-scope-btn') await createScopeBtn.tap()
await createScopeBtn.tap()
expect(await hasCurrentScope.text()).toBe('hasCurrentScope: true')
expect(await hasCurrentScope.text()).toBe('hasCurrentScope: true') })
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/is-proxy/is-proxy' const PAGE_PATH = '/pages/composition-api/reactivity/is-proxy/is-proxy'
describe('isProxy', () => { describe('isProxy', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const isProxyCount = await page.$('#is-proxy-count')
const isProxyCount = await page.$('#is-proxy-count') expect(await isProxyCount.text()).toBe('isProxy(count): false')
expect(await isProxyCount.text()).toBe('isProxy(count): false')
const isProxyRefCount = await page.$('#is-proxy-ref-count')
const isProxyRefCount = await page.$('#is-proxy-ref-count') expect(await isProxyRefCount.text()).toBe('isProxy(refCount): false')
expect(await isProxyRefCount.text()).toBe('isProxy(refCount): false')
const isProxyReactiveCount = await page.$('#is-proxy-reactive-count')
const isProxyReactiveCount = await page.$('#is-proxy-reactive-count') expect(await isProxyReactiveCount.text()).toBe('isProxy(reactiveCount): true')
expect(await isProxyReactiveCount.text()).toBe('isProxy(reactiveCount): true')
const isProxyReadonlyCount = await page.$('#is-proxy-readonly-count')
const isProxyReadonlyCount = await page.$('#is-proxy-readonly-count') expect(await isProxyReadonlyCount.text()).toBe('isProxy(readonlyCount): true')
expect(await isProxyReadonlyCount.text()).toBe('isProxy(readonlyCount): true')
const isProxyShallowReactiveCount = await page.$('#is-proxy-shallow-reactive-count')
const isProxyShallowReactiveCount = await page.$('#is-proxy-shallow-reactive-count') expect(await isProxyShallowReactiveCount.text()).toBe('isProxy(shallowReactiveCount): true')
expect(await isProxyShallowReactiveCount.text()).toBe('isProxy(shallowReactiveCount): true')
const isProxyShallowReadonlyCount = await page.$('#is-proxy-shallow-readonly-count')
const isProxyShallowReadonlyCount = await page.$('#is-proxy-shallow-readonly-count') expect(await isProxyShallowReadonlyCount.text()).toBe('isProxy(shallowReadonlyCount): true')
expect(await isProxyShallowReadonlyCount.text()).toBe('isProxy(shallowReadonlyCount): true') })
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/is-reactive/is-reactive' const PAGE_PATH = '/pages/composition-api/reactivity/is-reactive/is-reactive'
describe('isReactive', () => { describe('isReactive', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const isReactiveCount = await page.$('#is-reactive-count')
const isReactiveCount = await page.$('#is-reactive-count') expect(await isReactiveCount.text()).toBe('isReactive(count): false')
expect(await isReactiveCount.text()).toBe('isReactive(count): false')
const isReactiveRefCount = await page.$('#is-reactive-ref-count') const isReactiveRefCount = await page.$('#is-reactive-ref-count')
expect(await isReactiveRefCount.text()).toBe('isReactive(refCount): false') expect(await isReactiveRefCount.text()).toBe('isReactive(refCount): false')
const isReactiveReactiveCount = await page.$('#is-reactive-reactive-count') const isReactiveReactiveCount = await page.$('#is-reactive-reactive-count')
expect(await isReactiveReactiveCount.text()).toBe('isReactive(reactiveCount): true') expect(await isReactiveReactiveCount.text()).toBe('isReactive(reactiveCount): true')
const isReactiveReadonlyCount = await page.$('#is-reactive-readonly-count') const isReactiveReadonlyCount = await page.$('#is-reactive-readonly-count')
expect(await isReactiveReadonlyCount.text()).toBe('isReactive(readonlyCount): false') expect(await isReactiveReadonlyCount.text()).toBe('isReactive(readonlyCount): false')
const isReactiveShallowReactiveCount = await page.$('#is-reactive-shallow-reactive-count') const isReactiveShallowReactiveCount = await page.$('#is-reactive-shallow-reactive-count')
expect(await isReactiveShallowReactiveCount.text()).toBe('isReactive(shallowReactiveCount): true') expect(await isReactiveShallowReactiveCount.text()).toBe('isReactive(shallowReactiveCount): true')
const isReactiveShallowReadonlyCount = await page.$('#is-reactive-shallow-readonly-count') const isReactiveShallowReadonlyCount = await page.$('#is-reactive-shallow-readonly-count')
expect(await isReactiveShallowReadonlyCount.text()).toBe('isReactive(shallowReadonlyCount): false') expect(await isReactiveShallowReadonlyCount.text()).toBe('isReactive(shallowReadonlyCount): false')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/is-readonly/is-readonly' const PAGE_PATH = '/pages/composition-api/reactivity/is-readonly/is-readonly'
describe('isReadonly', () => { describe('isReadonly', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const isReadonlyCount = await page.$('#is-readonly-count')
const isReadonlyCount = await page.$('#is-readonly-count') expect(await isReadonlyCount.text()).toBe('isReadonly(count): false')
expect(await isReadonlyCount.text()).toBe('isReadonly(count): false')
const isReadonlyRefCount = await page.$('#is-readonly-ref-count') const isReadonlyRefCount = await page.$('#is-readonly-ref-count')
expect(await isReadonlyRefCount.text()).toBe('isReadonly(refCount): false') expect(await isReadonlyRefCount.text()).toBe('isReadonly(refCount): false')
const isReadonlyReactiveCount = await page.$('#is-readonly-reactive-count') const isReadonlyReactiveCount = await page.$('#is-readonly-reactive-count')
expect(await isReadonlyReactiveCount.text()).toBe('isReadonly(reactiveCount): false') expect(await isReadonlyReactiveCount.text()).toBe('isReadonly(reactiveCount): false')
const isReadonlyReadonlyCount = await page.$('#is-readonly-readonly-count') const isReadonlyReadonlyCount = await page.$('#is-readonly-readonly-count')
expect(await isReadonlyReadonlyCount.text()).toBe('isReadonly(readonlyCount): true') expect(await isReadonlyReadonlyCount.text()).toBe('isReadonly(readonlyCount): true')
const isReadonlyShallowReactiveCount = await page.$('#is-readonly-shallow-reactive-count') const isReadonlyShallowReactiveCount = await page.$('#is-readonly-shallow-reactive-count')
expect(await isReadonlyShallowReactiveCount.text()).toBe('isReadonly(shallowReactiveCount): false') expect(await isReadonlyShallowReactiveCount.text()).toBe('isReadonly(shallowReactiveCount): false')
const isReadonlyShallowReadonlyCount = await page.$('#is-readonly-shallow-readonly-count') const isReadonlyShallowReadonlyCount = await page.$('#is-readonly-shallow-readonly-count')
expect(await isReadonlyShallowReadonlyCount.text()).toBe('isReadonly(shallowReadonlyCount): true') expect(await isReadonlyShallowReadonlyCount.text()).toBe('isReadonly(shallowReadonlyCount): true')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/on-scope-dispose/on-scope-dispose' const PAGE_PATH = '/pages/composition-api/reactivity/on-scope-dispose/on-scope-dispose'
describe('onScopeDispose', () => { describe('onScopeDispose', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const hasCurrentScope = await page.$('#has-current-scope')
const hasCurrentScope = await page.$('#has-current-scope') expect(await hasCurrentScope.text()).toBe('hasCurrentScope: false')
expect(await hasCurrentScope.text()).toBe('hasCurrentScope: false')
const createScopeBtn = await page.$('#create-scope-btn') const createScopeBtn = await page.$('#create-scope-btn')
await createScopeBtn.tap() await createScopeBtn.tap()
expect(await hasCurrentScope.text()).toBe('hasCurrentScope: true') expect(await hasCurrentScope.text()).toBe('hasCurrentScope: true')
const stopScopeBtn = await page.$('#stop-scope-btn') const stopScopeBtn = await page.$('#stop-scope-btn')
await stopScopeBtn.tap() await stopScopeBtn.tap()
expect(await hasCurrentScope.text()).toBe('hasCurrentScope: false') expect(await hasCurrentScope.text()).toBe('hasCurrentScope: false')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/reactive/reactive' const PAGE_PATH = '/pages/composition-api/reactivity/reactive/reactive'
describe('reactive', () => { describe('reactive', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const count = await page.$('#count')
const count = await page.$('#count') expect(await count.text()).toBe('count: 0')
expect(await count.text()).toBe('count: 0')
const objStr = await page.$('#obj-str') const objStr = await page.$('#obj-str')
expect(await objStr.text()).toBe('obj.str: default str') expect(await objStr.text()).toBe('obj.str: default str')
const objNum = await page.$('#obj-num') const objNum = await page.$('#obj-num')
expect(await objNum.text()).toBe('obj.num: 0') expect(await objNum.text()).toBe('obj.num: 0')
const objArr = await page.$('#obj-arr') const objArr = await page.$('#obj-arr')
expect(await objArr.text()).toBe('obj.arr: ["a","b","c"]') expect(await objArr.text()).toBe('obj.arr: ["a","b","c"]')
const updateBtn = await page.$('#update-btn') const updateBtn = await page.$('#update-btn')
await updateBtn.tap() await updateBtn.tap()
expect(await count.text()).toBe('count: 2') expect(await count.text()).toBe('count: 2')
expect(await objStr.text()).toBe('obj.str: new str') expect(await objStr.text()).toBe('obj.str: new str')
expect(await objNum.text()).toBe('obj.num: 2') expect(await objNum.text()).toBe('obj.num: 2')
expect(await objArr.text()).toBe('obj.arr: ["a","b","c","d"]') expect(await objArr.text()).toBe('obj.arr: ["a","b","c","d"]')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/readonly/readonly' const PAGE_PATH = '/pages/composition-api/reactivity/readonly/readonly'
describe('ref', () => { describe('ref', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const dataStr = await page.$('#data-str')
const dataStr = await page.$('#data-str') expect(await dataStr.text()).toBe('data.str: default str')
expect(await dataStr.text()).toBe('data.str: default str') const dataNum = await page.$('#data-num')
const dataNum = await page.$('#data-num') expect(await dataNum.text()).toBe('data.num: 0')
expect(await dataNum.text()).toBe('data.num: 0') const dataArr = await page.$('#data-arr')
const dataArr = await page.$('#data-arr') expect(await dataArr.text()).toBe('data.arr: ["a","b","c"]')
expect(await dataArr.text()).toBe('data.arr: ["a","b","c"]')
const readonlyDataStr = await page.$('#readonly-data-str') const readonlyDataStr = await page.$('#readonly-data-str')
expect(await readonlyDataStr.text()).toBe('readonly data.str: default str') expect(await readonlyDataStr.text()).toBe('readonly data.str: default str')
const readonlyDataNum = await page.$('#readonly-data-num') const readonlyDataNum = await page.$('#readonly-data-num')
expect(await readonlyDataNum.text()).toBe('readonly data.num: 0') expect(await readonlyDataNum.text()).toBe('readonly data.num: 0')
const readonlyDataArr = await page.$('#readonly-data-arr') const readonlyDataArr = await page.$('#readonly-data-arr')
expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c"]') expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c"]')
const updateDataBtn = await page.$('#update-data-btn') const updateDataBtn = await page.$('#update-data-btn')
await updateDataBtn.tap() await updateDataBtn.tap()
expect(await dataStr.text()).toBe('data.str: new str') expect(await dataStr.text()).toBe('data.str: new str')
expect(await dataNum.text()).toBe('data.num: 1') expect(await dataNum.text()).toBe('data.num: 1')
expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]') expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]')
expect(await readonlyDataStr.text()).toBe('readonly data.str: new str') expect(await readonlyDataStr.text()).toBe('readonly data.str: new str')
expect(await readonlyDataNum.text()).toBe('readonly data.num: 1') expect(await readonlyDataNum.text()).toBe('readonly data.num: 1')
expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]') expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]')
const updateReadonlyDataBtn = await page.$('#update-readonly-data-btn') const updateReadonlyDataBtn = await page.$('#update-readonly-data-btn')
await updateReadonlyDataBtn.tap() await updateReadonlyDataBtn.tap()
expect(await dataStr.text()).toBe('data.str: new str') expect(await dataStr.text()).toBe('data.str: new str')
expect(await dataNum.text()).toBe('data.num: 1') expect(await dataNum.text()).toBe('data.num: 1')
expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]') expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]')
expect(await readonlyDataStr.text()).toBe('readonly data.str: new str') expect(await readonlyDataStr.text()).toBe('readonly data.str: new str')
expect(await readonlyDataNum.text()).toBe('readonly data.num: 1') expect(await readonlyDataNum.text()).toBe('readonly data.num: 1')
expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]') expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/shallow-readonly/shallow-readonly' const PAGE_PATH = '/pages/composition-api/reactivity/shallow-readonly/shallow-readonly'
describe('shallowReadonly', () => { describe('shallowReadonly', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { let stateCount = await page.$('#state-count')
let stateCount = await page.$('#state-count') expect(await stateCount.text()).toBe('state.count: 0')
expect(await stateCount.text()).toBe('state.count: 0')
let stateNestedCount = await page.$('#state-nested-count') let stateNestedCount = await page.$('#state-nested-count')
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') const incrementStateCountBtn = await page.$('#increment-state-count-btn')
await incrementStateCountBtn.tap() await incrementStateCountBtn.tap()
const incrementStateNestedCountBtn = await page.$('#increment-state-nested-count-btn') const incrementStateNestedCountBtn = await page.$('#increment-state-nested-count-btn')
await incrementStateNestedCountBtn.tap() await incrementStateNestedCountBtn.tap()
expect(await stateCount.text()).toBe('state.count: 0')
expect(await stateNestedCount.text()).toBe('state.nested.count: 0')
const updatePageRenderBtn = await page.$('#update-page-render-btn') expect(await stateCount.text()).toBe('state.count: 0')
await updatePageRenderBtn.tap() expect(await stateNestedCount.text()).toBe('state.nested.count: 0')
stateCount = await page.$('#state-count') const updatePageRenderBtn = await page.$('#update-page-render-btn')
expect(await stateCount.text()).toBe('state.count: 0') await updatePageRenderBtn.tap()
stateNestedCount = await page.$('#state-nested-count')
expect(await stateNestedCount.text()).toBe('state.nested.count: 1') stateCount = await page.$('#state-count')
}) expect(await stateCount.text()).toBe('state.count: 0')
} else { stateNestedCount = await page.$('#state-nested-count')
it('other platform', () => { expect(await stateNestedCount.text()).toBe('state.nested.count: 1')
expect(1).toBe(1) })
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/to-raw/to-raw' const PAGE_PATH = '/pages/composition-api/reactivity/to-raw/to-raw'
describe('toRaw', () => { describe('toRaw', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const checkToRawRef = await page.$('#check-to-raw-ref')
const checkToRawRef = await page.$('#check-to-raw-ref') expect(await checkToRawRef.text()).toBe('check toRaw ref: false')
expect(await checkToRawRef.text()).toBe('check toRaw ref: false')
const checkToRawReactive = await page.$('#check-to-raw-reactive') const checkToRawReactive = await page.$('#check-to-raw-reactive')
expect(await checkToRawReactive.text()).toBe('check toRaw reactive: true') expect(await checkToRawReactive.text()).toBe('check toRaw reactive: true')
const checkToRawReadonly = await page.$('#check-to-raw-readonly') const checkToRawReadonly = await page.$('#check-to-raw-readonly')
expect(await checkToRawReadonly.text()).toBe('check toRaw readonly: true') expect(await checkToRawReadonly.text()).toBe('check toRaw readonly: true')
const checkToRawShallowReactive = await page.$('#check-to-raw-shallow-reactive') const checkToRawShallowReactive = await page.$('#check-to-raw-shallow-reactive')
expect(await checkToRawShallowReactive.text()).toBe('check toRaw shallowReactive: true') expect(await checkToRawShallowReactive.text()).toBe('check toRaw shallowReactive: true')
const checkToRawShallowReadonly = await page.$('#check-to-raw-shallow-readonly') const checkToRawShallowReadonly = await page.$('#check-to-raw-shallow-readonly')
expect(await checkToRawShallowReadonly.text()).toBe('check toRaw shallowReadonly: true') expect(await checkToRawShallowReadonly.text()).toBe('check toRaw shallowReadonly: true')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/to-ref/to-ref' const PAGE_PATH = '/pages/composition-api/reactivity/to-ref/to-ref'
describe('toRef', () => { describe('toRef', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const count = await page.$('#count')
const count = await page.$('#count') expect(await count.text()).toBe('count: 0')
expect(await count.text()).toBe('count: 0') const isRefCount = await page.$('#is-ref-count')
const isRefCount = await page.$('#is-ref-count') expect(await isRefCount.text()).toBe('isRef count: false')
expect(await isRefCount.text()).toBe('isRef count: false') const refCount = await page.$('#ref-count')
const refCount = await page.$('#ref-count') expect(await refCount.text()).toBe('ref count: 0')
expect(await refCount.text()).toBe('ref count: 0') const isRefRefCount = await page.$('#is-ref-ref-count')
const isRefRefCount = await page.$('#is-ref-ref-count') expect(await isRefRefCount.text()).toBe('isRef ref count: true')
expect(await isRefRefCount.text()).toBe('isRef ref count: true')
const objNum = await page.$('#obj-num') const objNum = await page.$('#obj-num')
expect(await objNum.text()).toBe('obj.num: 0') expect(await objNum.text()).toBe('obj.num: 0')
const toRefObjNum = await page.$('#to-ref-obj-num') const toRefObjNum = await page.$('#to-ref-obj-num')
expect(await toRefObjNum.text()).toBe('toRef(obj, "num"): 0') expect(await toRefObjNum.text()).toBe('toRef(obj, "num"): 0')
const toRefFnObjNum = await page.$('#to-ref-fn-obj-num') const toRefFnObjNum = await page.$('#to-ref-fn-obj-num')
expect(await toRefFnObjNum.text()).toBe('toRef(() => obj.num): 0') expect(await toRefFnObjNum.text()).toBe('toRef(() => obj.num): 0')
const incrementBtn = await page.$('#increment-btn') const incrementBtn = await page.$('#increment-btn')
await incrementBtn.tap() await incrementBtn.tap()
expect(await objNum.text()).toBe('obj.num: 2') expect(await objNum.text()).toBe('obj.num: 2')
expect(await toRefObjNum.text()).toBe('toRef(obj, "num"): 2') expect(await toRefObjNum.text()).toBe('toRef(obj, "num"): 2')
expect(await toRefFnObjNum.text()).toBe('toRef(() => obj.num): 2') expect(await toRefFnObjNum.text()).toBe('toRef(() => obj.num): 2')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/to-refs/to-refs' const PAGE_PATH = '/pages/composition-api/reactivity/to-refs/to-refs'
describe('toRefs', () => { describe('toRefs', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const stateNum = await page.$('#state-num')
const stateNum = await page.$('#state-num') expect(await stateNum.text()).toBe('state.num: 0')
expect(await stateNum.text()).toBe('state.num: 0') const stateStr = await page.$('#state-str')
const stateStr = await page.$('#state-str') expect(await stateStr.text()).toBe('state.str: str-0')
expect(await stateStr.text()).toBe('state.str: str-0') const stateAsRefsNum = await page.$('#state-as-refs-num')
const stateAsRefsNum = await page.$('#state-as-refs-num') expect(await stateAsRefsNum.text()).toBe('stateAsRefs.num: 0')
expect(await stateAsRefsNum.text()).toBe('stateAsRefs.num: 0') const stateAsRefsStr = await page.$('#state-as-refs-str')
const stateAsRefsStr = await page.$('#state-as-refs-str') expect(await stateAsRefsStr.text()).toBe('stateAsRefs.str: str-0')
expect(await stateAsRefsStr.text()).toBe('stateAsRefs.str: str-0')
const updateStateBtn = await page.$('#update-state-btn') const updateStateBtn = await page.$('#update-state-btn')
await updateStateBtn.tap() await updateStateBtn.tap()
expect(await stateNum.text()).toBe('state.num: 1') expect(await stateNum.text()).toBe('state.num: 1')
expect(await stateStr.text()).toBe('state.str: str-1') expect(await stateStr.text()).toBe('state.str: str-1')
expect(await stateAsRefsNum.text()).toBe('stateAsRefs.num: 1') expect(await stateAsRefsNum.text()).toBe('stateAsRefs.num: 1')
expect(await stateAsRefsStr.text()).toBe('stateAsRefs.str: str-1') expect(await stateAsRefsStr.text()).toBe('stateAsRefs.str: str-1')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/to-value/to-value' const PAGE_PATH = '/pages/composition-api/reactivity/to-value/to-value'
describe('toValue', () => { describe('toValue', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { if (process.env.uniTestPlatformInfo.startsWith('web')) {
let page = null // TODO: web 端暂不支持
beforeAll(async () => { it('web', async () => {
page = await program.reLaunch(PAGE_PATH) expect(1).toBe(1)
await page.waitFor('view')
}) })
it('basic', async () => { }
const refCount = await page.$('#ref-count') let page = null
expect(await refCount.text()).toBe('ref count: 0') beforeAll(async () => {
const isRefRefCount = await page.$('#is-ref-ref-count') page = await program.reLaunch(PAGE_PATH)
expect(await isRefRefCount.text()).toBe('isRef ref count: true') await page.waitFor('view')
const count = await page.$('#count') })
expect(await count.text()).toBe('count: 0') it('basic', async () => {
const isRefCount = await page.$('#is-ref-count') const refCount = await page.$('#ref-count')
expect(await isRefCount.text()).toBe('isRef count: false') 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') const objNum = await page.$('#obj-num')
expect(await objNum.text()).toBe('obj.num: 0') expect(await objNum.text()).toBe('obj.num: 0')
const toValueObjNum = await page.$('#to-value-obj-num') const toValueObjNum = await page.$('#to-value-obj-num')
expect(await toValueObjNum.text()).toBe('toValue(() => obj.num): 0') expect(await toValueObjNum.text()).toBe('toValue(() => obj.num): 0')
const incrementBtn = await page.$('#increment-btn') const incrementBtn = await page.$('#increment-btn')
await incrementBtn.tap() await incrementBtn.tap()
expect(await objNum.text()).toBe('obj.num: 1') expect(await objNum.text()).toBe('obj.num: 1')
expect(await toValueObjNum.text()).toBe('toValue(() => 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
const PAGE_PATH = '/pages/composition-api/reactivity/trigger-ref/trigger-ref' const PAGE_PATH = '/pages/composition-api/reactivity/trigger-ref/trigger-ref'
describe('triggerRef', () => { describe('triggerRef', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const stateCount = await page.$('#state-count')
const stateCount = await page.$('#state-count') expect(await stateCount.text()).toBe('state.count: 0')
expect(await stateCount.text()).toBe('state.count: 0')
const incrementStateCountBtn = await page.$('#increment-state-count-btn') const incrementStateCountBtn = await page.$('#increment-state-count-btn')
await incrementStateCountBtn.tap() await incrementStateCountBtn.tap()
expect(await stateCount.text()).toBe('state.count: 0') expect(await stateCount.text()).toBe('state.count: 0')
const triggerRefStateBtn = await page.$('#trigger-ref-state-btn') const triggerRefStateBtn = await page.$('#trigger-ref-state-btn')
await triggerRefStateBtn.tap() await triggerRefStateBtn.tap()
expect(await stateCount.text()).toBe('state.count: 1') expect(await stateCount.text()).toBe('state.count: 1')
}) })
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/watch-post-effect/watch-post-effect' const PAGE_PATH = '/pages/composition-api/reactivity/watch-post-effect/watch-post-effect'
describe('watchPostEffect', () => { describe('watchPostEffect', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('count', async () => {
it('count', async () => { const count = await page.$('#count')
const count = await page.$('#count') expect(await count.text()).toBe('count: 0')
expect(await count.text()).toBe('count: 0')
// watch
// watch const watchCountRes = await page.$('#watch-count-res')
const watchCountRes = await page.$('#watch-count-res') expect(await watchCountRes.text()).toBe(
expect(await watchCountRes.text()).toBe( 'watch count result: count: 0, count ref text: count: 0')
'watch count result: count: 0, count ref text: count: 0')
// track
// track const watchCountTrackNum = await page.$('#watch-count-track-num')
const watchCountTrackNum = await page.$('#watch-count-track-num') expect(await watchCountTrackNum.text()).toBe('watch count track number: 3')
expect(await watchCountTrackNum.text()).toBe('watch count track number: 3')
// trigger
// trigger const watchCountTriggerNum = await page.$('#watch-count-trigger-num')
const watchCountTriggerNum = await page.$('#watch-count-trigger-num') expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 0')
expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 0') const watchCountCleanupRes = await page.$('#watch-count-cleanup-res')
const watchCountCleanupRes = await page.$('#watch-count-cleanup-res') expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: ')
expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: ')
// watch count and obj.num
// watch count and obj.num const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res')
const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res') expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 0, obj.num: 0')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 0, obj.num: 0')
const incrementBtn = await page.$('#increment-btn')
const incrementBtn = await page.$('#increment-btn') await incrementBtn.tap()
await incrementBtn.tap()
expect(await count.text()).toBe('count: 1')
expect(await count.text()).toBe('count: 1') expect(await watchCountRes.text()).toBe(
expect(await watchCountRes.text()).toBe( 'watch count result: count: 1, count ref text: count: 1')
'watch count result: count: 1, count ref text: count: 1') expect(await watchCountTrackNum.text()).toBe('watch count track number: 3')
expect(await watchCountTrackNum.text()).toBe('watch count track number: 3') expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 1')
expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 1') expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 1')
expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 1')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 1, obj.num: 0')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 1, obj.num: 0')
await incrementBtn.tap()
await incrementBtn.tap()
expect(await count.text()).toBe('count: 2')
expect(await count.text()).toBe('count: 2') expect(await watchCountRes.text()).toBe(
expect(await watchCountRes.text()).toBe( 'watch count result: count: 2, count ref text: count: 2')
'watch count result: count: 2, count ref text: count: 2') expect(await watchCountTrackNum.text()).toBe('watch count track number: 3')
expect(await watchCountTrackNum.text()).toBe('watch count track number: 3') expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 2')
expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 2') expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 2')
expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 2')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 2, obj.num: 0')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 2, obj.num: 0')
// stop watch
// stop watch const stopWatchCountBtn = await page.$('#stop-watch-count-btn')
const stopWatchCountBtn = await page.$('#stop-watch-count-btn') await stopWatchCountBtn.tap()
await stopWatchCountBtn.tap()
await incrementBtn.tap()
await incrementBtn.tap()
expect(await count.text()).toBe('count: 3')
expect(await count.text()).toBe('count: 3') expect(await watchCountRes.text()).toBe(
expect(await watchCountRes.text()).toBe( 'watch count result: count: 2, count ref text: count: 2')
'watch count result: count: 2, count ref text: count: 2') expect(await watchCountTrackNum.text()).toBe('watch count track number: 3')
expect(await watchCountTrackNum.text()).toBe('watch count track number: 3') expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 2')
expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 2') expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 2')
expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 2')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 3, obj.num: 0')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 3, obj.num: 0') })
}) it('obj', async () => {
it('obj', async () => { const objStr = await page.$('#obj-str')
const objStr = await page.$('#obj-str') expect(await objStr.text()).toBe('obj.str: num: 0')
expect(await objStr.text()).toBe('obj.str: num: 0') const objNum = await page.$('#obj-num')
const objNum = await page.$('#obj-num') expect(await objNum.text()).toBe('obj.num: 0')
expect(await objNum.text()).toBe('obj.num: 0') const objBool = await page.$('#obj-bool')
const objBool = await page.$('#obj-bool') expect(await objBool.text()).toBe('obj.bool: false')
expect(await objBool.text()).toBe('obj.bool: false') const objArr = await page.$('#obj-arr')
const objArr = await page.$('#obj-arr') expect(await objArr.text()).toBe('obj.arr: [0]')
expect(await objArr.text()).toBe('obj.arr: [0]')
const watchObjRes = await page.$('#watch-obj-res')
const watchObjRes = await page.$('#watch-obj-res') expect(await watchObjRes.text()).toBe(
expect(await watchObjRes.text()).toBe( 'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}')
'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}') const watchObjStrRes = await page.$('#watch-obj-str-res')
const watchObjStrRes = await page.$('#watch-obj-str-res') expect(await watchObjStrRes.text()).toBe(
expect(await watchObjStrRes.text()).toBe( 'watch obj.str result: str: num: 0, obj.str ref text: obj.str: num: 0')
'watch obj.str result: str: num: 0, obj.str ref text: obj.str: num: 0') const watchObjArrRes = await page.$('#watch-obj-arr-res')
const watchObjArrRes = await page.$('#watch-obj-arr-res') expect(await watchObjArrRes.text()).toBe('watch obj.arr result: arr: [0]')
expect(await watchObjArrRes.text()).toBe('watch obj.arr result: arr: [0]')
const updateObjBtn = await page.$('#update-obj-btn')
const updateObjBtn = await page.$('#update-obj-btn') await updateObjBtn.tap()
await updateObjBtn.tap()
expect(await objStr.text()).toBe('obj.str: num: 1')
expect(await objStr.text()).toBe('obj.str: num: 1') expect(await objNum.text()).toBe('obj.num: 1')
expect(await objNum.text()).toBe('obj.num: 1') expect(await objBool.text()).toBe('obj.bool: true')
expect(await objBool.text()).toBe('obj.bool: true') expect(await objArr.text()).toBe('obj.arr: [0,1]')
expect(await objArr.text()).toBe('obj.arr: [0,1]')
expect(await watchObjRes.text()).toBe(
expect(await watchObjRes.text()).toBe( 'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}')
'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}') expect(await watchObjStrRes.text()).toBe(
expect(await watchObjStrRes.text()).toBe( 'watch obj.str result: str: num: 1, obj.str ref text: obj.str: num: 1')
'watch obj.str result: str: num: 1, obj.str ref text: obj.str: num: 1') expect(await watchObjArrRes.text()).toBe('watch obj.arr result: arr: [0,1]')
expect(await watchObjArrRes.text()).toBe('watch obj.arr result: arr: [0,1]')
const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res')
const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res') expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 3, obj.num: 1')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 3, obj.num: 1') })
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect' const PAGE_PATH = '/pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect'
describe('watchSyncEffect', () => { describe('watchSyncEffect', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page = null
let page = null beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('count', async () => {
it('count', async () => { const count = await page.$('#count')
const count = await page.$('#count') expect(await count.text()).toBe('count: 0')
expect(await count.text()).toBe('count: 0')
// watch
// watch const watchCountRes = await page.$('#watch-count-res')
const watchCountRes = await page.$('#watch-count-res') expect(await watchCountRes.text()).toBe(
expect(await watchCountRes.text()).toBe( 'watch count result: count: 0, count ref text: count: 0')
'watch count result: count: 0, count ref text: count: 0')
// track
// track const watchCountTrackNum = await page.$('#watch-count-track-num')
const watchCountTrackNum = await page.$('#watch-count-track-num') expect(await watchCountTrackNum.text()).toBe('watch count track number: 3')
expect(await watchCountTrackNum.text()).toBe('watch count track number: 3')
// trigger
// trigger const watchCountTriggerNum = await page.$('#watch-count-trigger-num')
const watchCountTriggerNum = await page.$('#watch-count-trigger-num') expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 1')
expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 1') const watchCountCleanupRes = await page.$('#watch-count-cleanup-res')
const watchCountCleanupRes = await page.$('#watch-count-cleanup-res') expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 0')
expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 0')
// watch count and obj.num
// watch count and obj.num const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res')
const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res') expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 0, obj.num: 0')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 0, obj.num: 0')
const incrementBtn = await page.$('#increment-btn')
const incrementBtn = await page.$('#increment-btn') await incrementBtn.tap()
await incrementBtn.tap()
expect(await count.text()).toBe('count: 1')
expect(await count.text()).toBe('count: 1') expect(await watchCountRes.text()).toBe(
expect(await watchCountRes.text()).toBe( 'watch count result: count: 1, count ref text: count: 0')
'watch count result: count: 1, count ref text: count: 0') expect(await watchCountTrackNum.text()).toBe('watch count track number: 3')
expect(await watchCountTrackNum.text()).toBe('watch count track number: 3') expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 2')
expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 2') expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 1')
expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 1')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 1, obj.num: 0')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 1, obj.num: 0')
await incrementBtn.tap()
await incrementBtn.tap()
expect(await count.text()).toBe('count: 2')
expect(await count.text()).toBe('count: 2') expect(await watchCountRes.text()).toBe(
expect(await watchCountRes.text()).toBe( 'watch count result: count: 2, count ref text: count: 1')
'watch count result: count: 2, count ref text: count: 1') expect(await watchCountTrackNum.text()).toBe('watch count track number: 3')
expect(await watchCountTrackNum.text()).toBe('watch count track number: 3') expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 3')
expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 3') expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 2')
expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 2')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 2, obj.num: 0')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 2, obj.num: 0')
// stop watch
// stop watch const stopWatchCountBtn = await page.$('#stop-watch-count-btn')
const stopWatchCountBtn = await page.$('#stop-watch-count-btn') await stopWatchCountBtn.tap()
await stopWatchCountBtn.tap()
await incrementBtn.tap()
await incrementBtn.tap()
expect(await count.text()).toBe('count: 3')
expect(await count.text()).toBe('count: 3') expect(await watchCountRes.text()).toBe(
expect(await watchCountRes.text()).toBe( 'watch count result: count: 2, count ref text: count: 1')
'watch count result: count: 2, count ref text: count: 1') expect(await watchCountTrackNum.text()).toBe('watch count track number: 3')
expect(await watchCountTrackNum.text()).toBe('watch count track number: 3') expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 3')
expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 3') expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 2')
expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: watch count cleanup: 2')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 3, obj.num: 0')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 3, obj.num: 0') })
}) it('obj', async () => {
it('obj', async () => { const objStr = await page.$('#obj-str')
const objStr = await page.$('#obj-str') expect(await objStr.text()).toBe('obj.str: num: 0')
expect(await objStr.text()).toBe('obj.str: num: 0') const objNum = await page.$('#obj-num')
const objNum = await page.$('#obj-num') expect(await objNum.text()).toBe('obj.num: 0')
expect(await objNum.text()).toBe('obj.num: 0') const objBool = await page.$('#obj-bool')
const objBool = await page.$('#obj-bool') expect(await objBool.text()).toBe('obj.bool: false')
expect(await objBool.text()).toBe('obj.bool: false') const objArr = await page.$('#obj-arr')
const objArr = await page.$('#obj-arr') expect(await objArr.text()).toBe('obj.arr: [0]')
expect(await objArr.text()).toBe('obj.arr: [0]')
const watchObjRes = await page.$('#watch-obj-res')
const watchObjRes = await page.$('#watch-obj-res') expect(await watchObjRes.text()).toBe(
expect(await watchObjRes.text()).toBe( 'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}')
'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}') const watchObjStrRes = await page.$('#watch-obj-str-res')
const watchObjStrRes = await page.$('#watch-obj-str-res') expect(await watchObjStrRes.text()).toBe(
expect(await watchObjStrRes.text()).toBe( 'watch obj.str result: str: num: 0, obj.str ref text: obj.str: num: 0')
'watch obj.str result: str: num: 0, obj.str ref text: obj.str: num: 0') const watchObjArrRes = await page.$('#watch-obj-arr-res')
const watchObjArrRes = await page.$('#watch-obj-arr-res') expect(await watchObjArrRes.text()).toBe('watch obj.arr result: arr: [0]')
expect(await watchObjArrRes.text()).toBe('watch obj.arr result: arr: [0]')
const updateObjBtn = await page.$('#update-obj-btn')
const updateObjBtn = await page.$('#update-obj-btn') await updateObjBtn.tap()
await updateObjBtn.tap()
expect(await objStr.text()).toBe('obj.str: num: 1')
expect(await objStr.text()).toBe('obj.str: num: 1') expect(await objNum.text()).toBe('obj.num: 1')
expect(await objNum.text()).toBe('obj.num: 1') expect(await objBool.text()).toBe('obj.bool: true')
expect(await objBool.text()).toBe('obj.bool: true') expect(await objArr.text()).toBe('obj.arr: [0,1]')
expect(await objArr.text()).toBe('obj.arr: [0,1]')
expect(await watchObjRes.text()).toBe(
expect(await watchObjRes.text()).toBe( 'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}')
'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}') expect(await watchObjStrRes.text()).toBe(
expect(await watchObjStrRes.text()).toBe( 'watch obj.str result: str: num: 1, obj.str ref text: obj.str: num: 0')
'watch obj.str result: str: num: 1, obj.str ref text: obj.str: num: 0') expect(await watchObjArrRes.text()).toBe('watch obj.arr result: arr: [0,1]')
expect(await watchObjArrRes.text()).toBe('watch obj.arr result: arr: [0,1]')
const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res')
const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res') expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 3, obj.num: 1')
expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 3, obj.num: 1') })
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/composition/mixins/mixins-page2' const PAGE_PATH = '/pages/composition/mixins/mixins-page2'
describe('mixins-page2', () => { describe('mixins-page2', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { if (process.env.uniTestPlatformInfo.startsWith('web')) {
let page // TODO: web 端暂不支持
beforeAll(async () => { it('web', async () => {
page = await program.reLaunch(PAGE_PATH) expect(1).toBe(1)
await page.waitFor('view')
}) })
}
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view')
})
it('components', async () => { it('components', async () => {
const GlobalMixinComp1 = await page.$('.global-mixin-component-1') const GlobalMixinComp1 = await page.$('.global-mixin-component-1')
const GlobalMixinComp1Text = await GlobalMixinComp1.text() const GlobalMixinComp1Text = await GlobalMixinComp1.text()
expect(GlobalMixinComp1Text).toBe('global mixin component 1') expect(GlobalMixinComp1Text).toBe('global mixin component 1')
const GlobalChildMixinComp1 = await page.$( const GlobalChildMixinComp1 = await page.$(
'.global-child-mixin-component-1' '.global-child-mixin-component-1'
) )
const GlobalChildMixinComp1Text = await GlobalChildMixinComp1.text() const GlobalChildMixinComp1Text = await GlobalChildMixinComp1.text()
expect(GlobalChildMixinComp1Text).toBe('global child mixin component 1') expect(GlobalChildMixinComp1Text).toBe('global child mixin component 1')
const GlobalMixinComp2 = await page.$('.global-mixin-component-2') const GlobalMixinComp2 = await page.$('.global-mixin-component-2')
const GlobalMixinComp2Text = await GlobalMixinComp2.text() const GlobalMixinComp2Text = await GlobalMixinComp2.text()
expect(GlobalMixinComp2Text).toBe('global mixin component 2') expect(GlobalMixinComp2Text).toBe('global mixin component 2')
const GlobalChildMixinComp2 = await page.$( const GlobalChildMixinComp2 = await page.$(
'.global-child-mixin-component-2' '.global-child-mixin-component-2'
) )
const GlobalChildMixinComp2Text = await GlobalChildMixinComp2.text() const GlobalChildMixinComp2Text = await GlobalChildMixinComp2.text()
expect(GlobalChildMixinComp2Text).toBe('global child mixin component 2') expect(GlobalChildMixinComp2Text).toBe('global child mixin component 2')
const MixinComp1 = await page.$('.mixin-component-1') const MixinComp1 = await page.$('.mixin-component-1')
const MixinComp1Text = await MixinComp1.text() const MixinComp1Text = await MixinComp1.text()
expect(MixinComp1Text).toBe('mixin component 1') expect(MixinComp1Text).toBe('mixin component 1')
const ChildMixinComp1 = await page.$('.child-mixin-component-1') const ChildMixinComp1 = await page.$('.child-mixin-component-1')
const ChildMixinComp1Text = await ChildMixinComp1.text() const ChildMixinComp1Text = await ChildMixinComp1.text()
expect(ChildMixinComp1Text).toBe('child mixin component 1') expect(ChildMixinComp1Text).toBe('child mixin component 1')
const MixinComp2 = await page.$('.mixin-component-2') const MixinComp2 = await page.$('.mixin-component-2')
const MixinComp2Text = await MixinComp2.text() const MixinComp2Text = await MixinComp2.text()
expect(MixinComp2Text).toBe('mixin component 2') expect(MixinComp2Text).toBe('mixin component 2')
const ChildMixinComp2 = await page.$('.child-mixin-component-2') const ChildMixinComp2 = await page.$('.child-mixin-component-2')
const ChildMixinComp2Text = await ChildMixinComp2.text() const ChildMixinComp2Text = await ChildMixinComp2.text()
expect(ChildMixinComp2Text).toBe('child mixin component 2') expect(ChildMixinComp2Text).toBe('child mixin component 2')
const MixinCompForPage = await page.$('.component-for-page') const MixinCompForPage = await page.$('.component-for-page')
const MixinCompForPageText = await MixinCompForPage.text() const MixinCompForPageText = await MixinCompForPage.text()
expect(MixinCompForPageText).toBe('component for page') expect(MixinCompForPageText).toBe('component for page')
}) })
it('props', async () => { it('props', async () => {
const namesakeMixinProp = await page.$('.namesake-mixin-prop') const namesakeMixinProp = await page.$('.namesake-mixin-prop')
const namesakeMixinPropText = await namesakeMixinProp.text() const namesakeMixinPropText = await namesakeMixinProp.text()
expect(namesakeMixinPropText).toBe('页面内的同名 props') expect(namesakeMixinPropText).toBe('页面内的同名 props')
const namesakeChildMixinProp = await page.$('.namesake-child-mixin-prop') const namesakeChildMixinProp = await page.$('.namesake-child-mixin-prop')
const namesakeChildMixinPropText = await namesakeChildMixinProp.text() const namesakeChildMixinPropText = await namesakeChildMixinProp.text()
expect(namesakeChildMixinPropText).toBe('页面内的同名 child props') expect(namesakeChildMixinPropText).toBe('页面内的同名 child props')
}) })
it('data', async () => { it('data', async () => {
const namesakeMixinDataMsgEl = await page.$('.namesake-mixin-data-msg') const namesakeMixinDataMsgEl = await page.$('.namesake-mixin-data-msg')
const namesakeMixinDataMsg = await namesakeMixinDataMsgEl.text() const namesakeMixinDataMsg = await namesakeMixinDataMsgEl.text()
expect(namesakeMixinDataMsg).toBe('页面内的同名 data') expect(namesakeMixinDataMsg).toBe('页面内的同名 data')
const namesakeChildMixinDataMsgEl = await page.$( const namesakeChildMixinDataMsgEl = await page.$(
'.namesake-child-mixin-data-msg' '.namesake-child-mixin-data-msg'
) )
const namesakeChildMixinDataMsg = await namesakeChildMixinDataMsgEl.text() const namesakeChildMixinDataMsg = await namesakeChildMixinDataMsgEl.text()
expect(namesakeChildMixinDataMsg).toBe('页面内的同名 child data') expect(namesakeChildMixinDataMsg).toBe('页面内的同名 child data')
}) })
it('computed', async () => { it('computed', async () => {
const namesakeMixinComputed = await page.$('.namesake-mixin-computed') const namesakeMixinComputed = await page.$('.namesake-mixin-computed')
const namesakeMixinComputedText = await namesakeMixinComputed.text() const namesakeMixinComputedText = await namesakeMixinComputed.text()
expect(namesakeMixinComputedText).toBe('页面内的同名 computed') expect(namesakeMixinComputedText).toBe('页面内的同名 computed')
const namesakeChildMixinComputed = await page.$( const namesakeChildMixinComputed = await page.$(
'.namesake-child-mixin-computed' '.namesake-child-mixin-computed'
) )
const namesakeChildMixinComputedText = const namesakeChildMixinComputedText =
await namesakeChildMixinComputed.text() await namesakeChildMixinComputed.text()
expect(namesakeChildMixinComputedText).toBe('页面内的同名 child computed') expect(namesakeChildMixinComputedText).toBe('页面内的同名 child computed')
}) })
it('method', async () => { it('method', async () => {
const namesakeMixinMethod = await page.$('.namesake-mixin-method') const namesakeMixinMethod = await page.$('.namesake-mixin-method')
const namesakeMixinMethodText = await namesakeMixinMethod.text() const namesakeMixinMethodText = await namesakeMixinMethod.text()
expect(namesakeMixinMethodText).toBe('页面内的同名 method') expect(namesakeMixinMethodText).toBe('页面内的同名 method')
const namesakeChildMixinMethod = await page.$( const namesakeChildMixinMethod = await page.$(
'.namesake-child-mixin-method' '.namesake-child-mixin-method'
) )
const namesakeChildMixinMethodText = await namesakeChildMixinMethod.text() const namesakeChildMixinMethodText = await namesakeChildMixinMethod.text()
expect(namesakeChildMixinMethodText).toBe('页面内的同名 child method') expect(namesakeChildMixinMethodText).toBe('页面内的同名 child method')
}) })
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
}) })
const PAGE_PATH = '/pages/composition/provide/provide-page2' const PAGE_PATH = '/pages/composition/provide/provide-page2'
describe('函数方式创建 provide', () => { describe('函数方式创建 provide', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page
let page beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('variable', async () => {
it('variable', async () => { const providePageTitleEl = await page.$('.provide-page-title')
const providePageTitleEl = await page.$('.provide-page-title') const providePageTitleText = await providePageTitleEl.text()
const providePageTitleText = await providePageTitleEl.text() expect(providePageTitleText).toBe(
expect(providePageTitleText).toBe( 'providePageTitle: 函数方式定义 provide page title'
'providePageTitle: 函数方式定义 provide page title' )
) })
}) it('string', async () => {
it('string', async () => { const providePageStrEl = await page.$('.provide-page-str')
const providePageStrEl = await page.$('.provide-page-str') const providePageStrText = await providePageStrEl.text()
const providePageStrText = await providePageStrEl.text() expect(providePageStrText).toBe(
expect(providePageStrText).toBe( 'providePageStr: 函数方式定义 provide page str'
'providePageStr: 函数方式定义 provide page str' )
) })
}) it('number', async () => {
it('number', async () => { const providePageNumEl = await page.$('.provide-page-num')
const providePageNumEl = await page.$('.provide-page-num') const providePageNumText = await providePageNumEl.text()
const providePageNumText = await providePageNumEl.text() expect(providePageNumText).toBe('providePageNum: 2')
expect(providePageNumText).toBe('providePageNum: 2') })
}) it('boolean', async () => {
it('boolean', async () => { const providePageBoolEl = await page.$('.provide-page-bool')
const providePageBoolEl = await page.$('.provide-page-bool') const providePageBoolText = await providePageBoolEl.text()
const providePageBoolText = await providePageBoolEl.text() expect(providePageBoolText).toBe('providePageBool: true')
expect(providePageBoolText).toBe('providePageBool: true') })
}) it('object', async () => {
it('object', async () => { const providePageObjectTitleEl = await page.$(
const providePageObjectTitleEl = await page.$( '.provide-page-object-title'
'.provide-page-object-title' )
) const providePageObjectTitleText = await providePageObjectTitleEl.text()
const providePageObjectTitleText = await providePageObjectTitleEl.text() expect(providePageObjectTitleText).toBe(
expect(providePageObjectTitleText).toBe( 'providePageObject.title: 函数方式定义 provide page object title'
'providePageObject.title: 函数方式定义 provide page object title' )
) const providePageObjectContentEl = await page.$(
const providePageObjectContentEl = await page.$( '.provide-page-object-content'
'.provide-page-object-content' )
) const providePageObjectContentText =
const providePageObjectContentText = await providePageObjectContentEl.text()
await providePageObjectContentEl.text() expect(providePageObjectContentText).toBe(
expect(providePageObjectContentText).toBe( 'providePageObject.content: 函数方式定义 provide page object content'
'providePageObject.content: 函数方式定义 provide page object content' )
) })
}) it('array', async () => {
it('array', async () => { const providePageArrEl = await page.$('.provide-page-arr')
const providePageArrEl = await page.$('.provide-page-arr') const providePageArrText = await providePageArrEl.text()
const providePageArrText = await providePageArrEl.text() expect(providePageArrText).toBe(
expect(providePageArrText).toBe( 'providePageArr: ["函数方式定义 provide page arr"]'
'providePageArr: ["函数方式定义 provide page arr"]' )
) })
}) it('map', async () => {
it('map', async () => { const providePageMapEl = await page.$('.provide-page-map')
const providePageMapEl = await page.$('.provide-page-map') const providePageMapText = await providePageMapEl.text()
const providePageMapText = await providePageMapEl.text() expect(providePageMapText).toBe(
expect(providePageMapText).toBe( 'providePageMap: {"key":"函数方式定义 provide page map"}'
'providePageMap: {"key":"函数方式定义 provide page map"}' )
) })
}) it('set', async () => {
it('set', async () => { const providePageSetEl = await page.$('.provide-page-set')
const providePageSetEl = await page.$('.provide-page-set') const providePageSetText = await providePageSetEl.text()
const providePageSetText = await providePageSetEl.text() expect(providePageSetText).toBe(
expect(providePageSetText).toBe( 'providePageSet: ["函数方式定义 provide page set"]'
'providePageSet: ["函数方式定义 provide page set"]' )
) })
})
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
}) })
const PAGE_PATH = '/pages/composition/provide/provide' const PAGE_PATH = '/pages/composition/provide/provide'
describe('字面量方式创建 provide', () => { describe('字面量方式创建 provide', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page
let page beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('alias', async () => {
it('alias', async () => { const aliasProvidePageTitleEl = await page.$('.alias-provide-page-title')
const aliasProvidePageTitleEl = await page.$('.alias-provide-page-title') const aliasProvidePageTitleText = await aliasProvidePageTitleEl.text()
const aliasProvidePageTitleText = await aliasProvidePageTitleEl.text() expect(aliasProvidePageTitleText).toBe(
expect(aliasProvidePageTitleText).toBe( 'aliasProvidePageTitle: default alias provide page title'
'aliasProvidePageTitle: default alias provide page title' )
) })
}) it('string', async () => {
it('string', async () => { const providePageStrEl = await page.$('.provide-page-str')
const providePageStrEl = await page.$('.provide-page-str') const providePageStrText = await providePageStrEl.text()
const providePageStrText = await providePageStrEl.text() expect(providePageStrText).toBe(
expect(providePageStrText).toBe( 'providePageStr: 字面量方式定义 provide page str'
'providePageStr: 字面量方式定义 provide page str' )
) })
}) it('number', async () => {
it('number', async () => { const providePageNumEl = await page.$('.provide-page-num')
const providePageNumEl = await page.$('.provide-page-num') const providePageNumText = await providePageNumEl.text()
const providePageNumText = await providePageNumEl.text() expect(providePageNumText).toBe('providePageNum: 1')
expect(providePageNumText).toBe('providePageNum: 1') })
}) it('boolean', async () => {
it('boolean', async () => { const providePageBoolEl = await page.$('.provide-page-bool')
const providePageBoolEl = await page.$('.provide-page-bool') const providePageBoolText = await providePageBoolEl.text()
const providePageBoolText = await providePageBoolEl.text() expect(providePageBoolText).toBe('providePageBool: true')
expect(providePageBoolText).toBe('providePageBool: true') })
}) it('object', async () => {
it('object', async () => { const providePageObjectTitleEl = await page.$(
const providePageObjectTitleEl = await page.$( '.provide-page-object-title'
'.provide-page-object-title' )
) const providePageObjectTitleText = await providePageObjectTitleEl.text()
const providePageObjectTitleText = await providePageObjectTitleEl.text() expect(providePageObjectTitleText).toBe(
expect(providePageObjectTitleText).toBe( 'providePageObject.title: 字面量方式定义 provide page object title'
'providePageObject.title: 字面量方式定义 provide page object title' )
) const providePageObjectContentEl = await page.$(
const providePageObjectContentEl = await page.$( '.provide-page-object-content'
'.provide-page-object-content' )
) const providePageObjectContentText =
const providePageObjectContentText = await providePageObjectContentEl.text()
await providePageObjectContentEl.text() expect(providePageObjectContentText).toBe(
expect(providePageObjectContentText).toBe( 'providePageObject.content: 字面量方式定义 provide page object content'
'providePageObject.content: 字面量方式定义 provide page object content' )
) })
}) it('array', async () => {
it('array', async () => { const providePageArrEl = await page.$('.provide-page-arr')
const providePageArrEl = await page.$('.provide-page-arr') const providePageArrText = await providePageArrEl.text()
const providePageArrText = await providePageArrEl.text() expect(providePageArrText).toBe(
expect(providePageArrText).toBe( 'providePageArr: ["字面量方式定义 provide page arr"]'
'providePageArr: ["字面量方式定义 provide page arr"]' )
) })
}) it('map', async () => {
it('map', async () => { const providePageMapEl = await page.$('.provide-page-map')
const providePageMapEl = await page.$('.provide-page-map') const providePageMapText = await providePageMapEl.text()
const providePageMapText = await providePageMapEl.text() expect(providePageMapText).toBe(
expect(providePageMapText).toBe( 'providePageMap: {"key":"字面量方式定义 provide page map"}'
'providePageMap: {"key":"字面量方式定义 provide page map"}' )
) })
}) it('set', async () => {
it('set', async () => { const providePageSetEl = await page.$('.provide-page-set')
const providePageSetEl = await page.$('.provide-page-set') const providePageSetText = await providePageSetEl.text()
const providePageSetText = await providePageSetEl.text() expect(providePageSetText).toBe(
expect(providePageSetText).toBe( 'providePageSet: ["字面量方式定义 provide page set"]'
'providePageSet: ["字面量方式定义 provide page set"]' )
) })
}) it('string default value', async () => {
it('string default value', async () => { const testInjectStringDefaultValueEl = await page.$(
const testInjectStringDefaultValueEl = await page.$( '.test-inject-string-default-value'
'.test-inject-string-default-value' )
) const testInjectStringDefaultValueText =
const testInjectStringDefaultValueText = await testInjectStringDefaultValueEl.text()
await testInjectStringDefaultValueEl.text() expect(testInjectStringDefaultValueText).toBe(
expect(testInjectStringDefaultValueText).toBe( 'testInjectStringDefaultValue: test inject string default value'
'testInjectStringDefaultValue: test inject string default value' )
) })
}) it('object default value', async () => {
it('object default value', async () => { const testInjectObjectDefaultValueTitleEl = await page.$(
const testInjectObjectDefaultValueTitleEl = await page.$( '.test-inject-object-default-value-title'
'.test-inject-object-default-value-title' )
) const testInjectObjectDefaultValueTitleText =
const testInjectObjectDefaultValueTitleText = await testInjectObjectDefaultValueTitleEl.text()
await testInjectObjectDefaultValueTitleEl.text() expect(testInjectObjectDefaultValueTitleText).toBe(
expect(testInjectObjectDefaultValueTitleText).toBe( 'testInjectObjectDefaultValue.title: test inject object default value title'
'testInjectObjectDefaultValue.title: test inject object default value title' )
)
const testInjectObjectDefaultValueContentEl = await page.$( const testInjectObjectDefaultValueContentEl = await page.$(
'.test-inject-object-default-value-content' '.test-inject-object-default-value-content'
) )
const testInjectObjectDefaultValueContentText = const testInjectObjectDefaultValueContentText =
await testInjectObjectDefaultValueContentEl.text() await testInjectObjectDefaultValueContentEl.text()
expect(testInjectObjectDefaultValueContentText).toBe( expect(testInjectObjectDefaultValueContentText).toBe(
'testInjectObjectDefaultValue.content: test inject object default value content' 'testInjectObjectDefaultValue.content: test inject object default value content'
) )
}) })
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
}) })
const PAGE_PATH = '/pages/composition/setup/setup' const PAGE_PATH = '/pages/composition/setup/setup'
describe('options setup', () => { describe('options setup', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page
let page beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const str = await page.$('#str')
const str = await page.$('#str') expect(await str.text()).toBe('str: default str')
expect(await str.text()).toBe('str: default str') const num = await page.$('#num')
const num = await page.$('#num') expect(await num.text()).toBe('num: 0')
expect(await num.text()).toBe('num: 0') const bool = await page.$('#bool')
const bool = await page.$('#bool') expect(await bool.text()).toBe('bool: false')
expect(await bool.text()).toBe('bool: false')
const count = await page.$('#count')
const count = await page.$('#count') expect(await count.text()).toBe('count: 0')
expect(await count.text()).toBe('count: 0')
const objStr = await page.$('#obj-str')
const objStr = await page.$('#obj-str') expect(await objStr.text()).toBe('obj.str: obj default str')
expect(await objStr.text()).toBe('obj.str: obj default str') const objNum = await page.$('#obj-num')
const objNum = await page.$('#obj-num') expect(await objNum.text()).toBe('obj.num: 0')
expect(await objNum.text()).toBe('obj.num: 0') const objBool = await page.$('#obj-bool')
const objBool = await page.$('#obj-bool') expect(await objBool.text()).toBe('obj.bool: false')
expect(await objBool.text()).toBe('obj.bool: false')
const propsStr = await page.$('#props-str')
const propsStr = await page.$('#props-str') expect(await propsStr.text()).toBe('props.str: default str')
expect(await propsStr.text()).toBe('props.str: default str') const propsCount = await page.$('#props-count')
const propsCount = await page.$('#props-count') expect(await propsCount.text()).toBe('props.count: 0')
expect(await propsCount.text()).toBe('props.count: 0') const propsObjStr = await page.$('#props-obj-str')
const propsObjStr = await page.$('#props-obj-str') expect(await propsObjStr.text()).toBe(`props.obj['str']: obj default str`)
expect(await propsObjStr.text()).toBe(`props.obj['str']: obj default str`) const propsObjNum = await page.$('#props-obj-num')
const propsObjNum = await page.$('#props-obj-num') expect(await propsObjNum.text()).toBe(`props.obj['num']: 0`)
expect(await propsObjNum.text()).toBe(`props.obj['num']: 0`) const propsObjBool = await page.$('#props-obj-bool')
const propsObjBool = await page.$('#props-obj-bool') expect(await propsObjBool.text()).toBe(`props.obj['bool']: false`)
expect(await propsObjBool.text()).toBe(`props.obj['bool']: false`) })
}) it('props', async () => {
it('props', async () => { const incrementBtn = await page.$('#increment-btn')
const incrementBtn = await page.$('#increment-btn') await incrementBtn.tap()
await incrementBtn.tap()
const count = await page.$('#count')
const count = await page.$('#count') expect(await count.text()).toBe('count: 1')
expect(await count.text()).toBe('count: 1') const propsCount = await page.$('#props-count')
const propsCount = await page.$('#props-count') expect(await propsCount.text()).toBe('props.count: 1')
expect(await propsCount.text()).toBe('props.count: 1')
const updateObjBtn = await page.$('#update-obj-btn')
const updateObjBtn = await page.$('#update-obj-btn') await updateObjBtn.tap()
await updateObjBtn.tap()
const objStr = await page.$('#obj-str')
const objStr = await page.$('#obj-str') expect(await objStr.text()).toBe('obj.str: obj new str')
expect(await objStr.text()).toBe('obj.str: obj new str') const objNum = await page.$('#obj-num')
const objNum = await page.$('#obj-num') expect(await objNum.text()).toBe('obj.num: 100')
expect(await objNum.text()).toBe('obj.num: 100') const objBool = await page.$('#obj-bool')
const objBool = await page.$('#obj-bool') expect(await objBool.text()).toBe('obj.bool: true')
expect(await objBool.text()).toBe('obj.bool: true')
const propsObjStr = await page.$('#props-obj-str')
const propsObjStr = await page.$('#props-obj-str') expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str`)
expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str`) const propsObjNum = await page.$('#props-obj-num')
const propsObjNum = await page.$('#props-obj-num') expect(await propsObjNum.text()).toBe(`props.obj['num']: 100`)
expect(await propsObjNum.text()).toBe(`props.obj['num']: 100`) const propsObjBool = await page.$('#props-obj-bool')
const propsObjBool = await page.$('#props-obj-bool') expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`)
expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`) })
}) it('context', async () => {
it('context', async () => { // attrs
// attrs const contextAttrsIsShow = await page.$('#context-attrs-is-show')
const contextAttrsIsShow = await page.$('#context-attrs-is-show') expect(await contextAttrsIsShow.text()).toBe('context.attrs.isShow: true')
expect(await contextAttrsIsShow.text()).toBe('context.attrs.isShow: true') // emits
// emits const compUpdateObjBtn = await page.$('#comp-update-obj-btn')
const compUpdateObjBtn = await page.$('#comp-update-obj-btn') await compUpdateObjBtn.tap()
await compUpdateObjBtn.tap() const propsObjStr = await page.$('#props-obj-str')
const propsObjStr = await page.$('#props-obj-str') expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str by comp update`)
expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str by comp update`) const propsObjNum = await page.$('#props-obj-num')
const propsObjNum = await page.$('#props-obj-num') expect(await propsObjNum.text()).toBe(`props.obj['num']: 200`)
expect(await propsObjNum.text()).toBe(`props.obj['num']: 200`) const propsObjBool = await page.$('#props-obj-bool')
const propsObjBool = await page.$('#props-obj-bool') expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`)
expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`) // slots
// slots const defaultSlotInFoo = await page.$('#default-slot-in-foo')
const defaultSlotInFoo = await page.$('#default-slot-in-foo') expect(await defaultSlotInFoo.text()).toBe('default slot in Foo')
expect(await defaultSlotInFoo.text()).toBe('default slot in Foo') const hasDefaultSlot = await page.$('#has-default-slot')
const hasDefaultSlot = await page.$('#has-default-slot') expect(await hasDefaultSlot.text()).toBe('hasDefaultSlot: true')
expect(await hasDefaultSlot.text()).toBe('hasDefaultSlot: true') })
})
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
const PAGE_PATH = '/pages/directive/v-memo/v-memo' const PAGE_PATH = '/pages/directive/v-memo/v-memo'
describe('v-memo', () => { describe('v-memo', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page
let page beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const equivalentVOnceTextEl = await page.$('.equivalent-v-once-text')
const equivalentVOnceTextEl = await page.$('.equivalent-v-once-text') let equivalentVOnceTextText = await equivalentVOnceTextEl.text()
let equivalentVOnceTextText = await equivalentVOnceTextEl.text() expect(equivalentVOnceTextText).toBe(
expect(equivalentVOnceTextText).toBe( 'This will never change: hello world'
'This will never change: hello world' )
)
const vMemoTextEl = await page.$('.v-memo-text') const vMemoTextEl = await page.$('.v-memo-text')
let vMemoTextText = await vMemoTextEl.text() let vMemoTextText = await vMemoTextEl.text()
expect(vMemoTextText).toBe( expect(vMemoTextText).toBe(
'This will change when num change, msg: hello world, num: 0' 'This will change when num change, msg: hello world, num: 0'
) )
const changeMessageBtn = await page.$('.change-message-btn') const changeMessageBtn = await page.$('.change-message-btn')
await changeMessageBtn.tap() await changeMessageBtn.tap()
const msg = await page.data('msg') const msg = await page.data('msg')
expect(msg).toBe('msg changed') expect(msg).toBe('msg changed')
equivalentVOnceTextText = await equivalentVOnceTextEl.text() equivalentVOnceTextText = await equivalentVOnceTextEl.text()
expect(equivalentVOnceTextText).toBe( expect(equivalentVOnceTextText).toBe(
'This will never change: hello world' 'This will never change: hello world'
) )
vMemoTextText = await vMemoTextEl.text() vMemoTextText = await vMemoTextEl.text()
expect(vMemoTextText).toBe( expect(vMemoTextText).toBe(
'This will change when num change, msg: hello world, num: 0' 'This will change when num change, msg: hello world, num: 0'
) )
const plusNumBtn = await page.$('.plus-num-btn') const plusNumBtn = await page.$('.plus-num-btn')
await plusNumBtn.tap() await plusNumBtn.tap()
vMemoTextText = await vMemoTextEl.text() vMemoTextText = await vMemoTextEl.text()
expect(vMemoTextText).toBe( expect(vMemoTextText).toBe(
'This will change when num change, msg: msg changed, num: 1' 'This will change when num change, msg: msg changed, num: 1'
) )
}) })
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
}) })
const PAGE_PATH = '/pages/directive/v-once/v-once' const PAGE_PATH = '/pages/directive/v-once/v-once'
describe('v-once', () => { describe('v-once', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { let page
let page beforeAll(async () => {
beforeAll(async () => { page = await program.reLaunch(PAGE_PATH)
page = await program.reLaunch(PAGE_PATH) await page.waitFor('view')
await page.waitFor('view') })
}) it('basic', async () => {
it('basic', async () => { const vOnceTextEl = await page.$('.v-once-text')
const vOnceTextEl = await page.$('.v-once-text') let vOnceTextText = await vOnceTextEl.text()
let vOnceTextText = await vOnceTextEl.text() expect(vOnceTextText).toBe('This will never change: hello world')
expect(vOnceTextText).toBe('This will never change: hello world')
const btn = await page.$('.btn') const btn = await page.$('.btn')
await btn.tap() await btn.tap()
const msg = await page.data('msg') const msg = await page.data('msg')
expect(msg).toBe('msg changed') expect(msg).toBe('msg changed')
vOnceTextText = await vOnceTextEl.text() vOnceTextText = await vOnceTextEl.text()
expect(vOnceTextText).toBe('This will never change: hello world') expect(vOnceTextText).toBe('This will never change: hello world')
}) })
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
}) })
\ No newline at end of file
describe('/pages/rendering/render/render', () => { describe('/pages/rendering/render/render', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) { if (process.env.uniTestPlatformInfo.startsWith('web')) {
let page
beforeAll(async () => {
page = await program.reLaunch('/pages/rendering/render/render')
await page.waitFor('view')
})
it('component', async () => {
const ComForRenderFunction = await page.$('.component-for-render-function')
expect(await ComForRenderFunction.text()).toEqual(
'component for render function'
)
const compSlot = await page.$('.comp-slot')
console.log('compSlot', compSlot)
expect(await compSlot.text()).toEqual('component slot')
})
it('text', async () => {
const 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')
expect(await msgEl.text()).toEqual('new msg')
})
} else {
// TODO: web 端暂不支持 // TODO: web 端暂不支持
it('web', async () => { it('web', async () => {
expect(1).toBe(1) expect(1).toBe(1)
}) })
} }
let page
beforeAll(async () => {
page = await program.reLaunch('/pages/rendering/render/render')
await page.waitFor('view')
})
it('component', async () => {
const ComForRenderFunction = await page.$('.component-for-render-function')
expect(await ComForRenderFunction.text()).toEqual(
'component for render function'
)
const compSlot = await page.$('.comp-slot')
console.log('compSlot', compSlot)
expect(await compSlot.text()).toEqual('component slot')
})
it('text', async () => {
const 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')
expect(await msgEl.text()).toEqual('new msg')
})
}) })
\ No newline at end of file
...@@ -55,12 +55,7 @@ ...@@ -55,12 +55,7 @@
{ {
name: 'defineExpose', name: 'defineExpose',
url: 'define-expose', url: 'define-expose',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'defineOptions', name: 'defineOptions',
...@@ -75,22 +70,12 @@ ...@@ -75,22 +70,12 @@
{ {
name: 'defineModel', name: 'defineModel',
url: 'define-model', url: 'define-model',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'useSlots', name: 'useSlots',
url: 'use-slots', url: 'use-slots',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'useAttrs', name: 'useAttrs',
...@@ -116,22 +101,12 @@ ...@@ -116,22 +101,12 @@
{ {
name: 'reactive', name: 'reactive',
url: 'reactive', url: 'reactive',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'readonly', name: 'readonly',
url: 'readonly', url: 'readonly',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'watch', name: 'watch',
...@@ -146,22 +121,12 @@ ...@@ -146,22 +121,12 @@
{ {
name: 'watchPostEffect', name: 'watchPostEffect',
url: 'watch-post-effect', url: 'watch-post-effect',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'watchSyncEffect', name: 'watchSyncEffect',
url: 'watch-sync-effect', url: 'watch-sync-effect',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'isRef', name: 'isRef',
...@@ -176,12 +141,7 @@ ...@@ -176,12 +141,7 @@
{ {
name: 'toRef', name: 'toRef',
url: 'to-ref', url: 'to-ref',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'toValue', name: 'toValue',
...@@ -196,42 +156,22 @@ ...@@ -196,42 +156,22 @@
{ {
name: 'toRefs', name: 'toRefs',
url: 'to-refs', url: 'to-refs',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'isProxy', name: 'isProxy',
url: 'is-proxy', url: 'is-proxy',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'isReactive', name: 'isReactive',
url: 'is-reactive', url: 'is-reactive',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'isReadonly', name: 'isReadonly',
url: 'is-readonly', url: 'is-readonly',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'shallowRef', name: 'shallowRef',
...@@ -241,22 +181,12 @@ ...@@ -241,22 +181,12 @@
{ {
name: 'triggerRef', name: 'triggerRef',
url: 'trigger-ref', url: 'trigger-ref',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'customRef', name: 'customRef',
url: 'custom-ref', url: 'custom-ref',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'shallowReactive', name: 'shallowReactive',
...@@ -266,22 +196,12 @@ ...@@ -266,22 +196,12 @@
{ {
name: 'shallowReadonly', name: 'shallowReadonly',
url: 'shallow-readonly', url: 'shallow-readonly',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'toRaw', name: 'toRaw',
url: 'to-raw', url: 'to-raw',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'markRaw', name: 'markRaw',
...@@ -291,32 +211,17 @@ ...@@ -291,32 +211,17 @@
{ {
name: 'effectScope', name: 'effectScope',
url: 'effect-scope', url: 'effect-scope',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'getCurrentScope', name: 'getCurrentScope',
url: 'get-current-scope', url: 'get-current-scope',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: 'onScopeDispose', name: 'onScopeDispose',
url: 'on-scope-dispose', url: 'on-scope-dispose',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
] as PageItem[], ] as PageItem[],
}, { }, {
...@@ -327,22 +232,12 @@ ...@@ -327,22 +232,12 @@
{ {
name: '页面生命周期', name: '页面生命周期',
url: 'page-lifecycle', url: 'page-lifecycle',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: '组件生命周期', name: '组件生命周期',
url: 'component-lifecycle', url: 'component-lifecycle',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
] ]
}, { }, {
...@@ -353,12 +248,7 @@ ...@@ -353,12 +248,7 @@
{ {
name: 'provide', name: 'provide',
url: 'provide', url: 'provide',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
} }
] ]
} }
......
...@@ -181,22 +181,12 @@ ...@@ -181,22 +181,12 @@
{ {
name: 'v-once', name: 'v-once',
url: 'v-once', url: 'v-once',
// #ifdef APP-ANDROID
enable: true, enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
}, },
{ {
name: 'v-memo', name: 'v-memo',
url: 'v-memo', url: 'v-memo',
// #ifdef APP-ANDROID
enable: true, enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
}, },
{ {
name: 'v-cloak', name: 'v-cloak',
...@@ -337,12 +327,7 @@ ...@@ -337,12 +327,7 @@
{ {
name: '$forceUpdate', name: '$forceUpdate',
url: 'force-update', url: 'force-update',
// #ifdef APP-ANDROID
enable: true, enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
}, },
{ {
name: '$nextTick', name: '$nextTick',
...@@ -384,32 +369,17 @@ ...@@ -384,32 +369,17 @@
{ {
name: 'provide', name: 'provide',
url: 'provide', url: 'provide',
// #ifdef APP-ANDROID
enable: true, enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
}, },
{ {
name: 'inject', name: 'inject',
url: 'inject', url: 'inject',
// #ifdef APP-ANDROID
enable: true, enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
}, },
{ {
name: 'mixins', name: 'mixins',
url: 'mixins', url: 'mixins',
// #ifdef APP-ANDROID
enable: true, enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
}, },
{ {
name: 'extends', name: 'extends',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册