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

feat: 开放部分web端测试例

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