提交 0badb02b 编写于 作者: H hdx

feat: add test files(v-if v-slot v-once)

上级 2f9738eb
......@@ -6,9 +6,20 @@ describe('v-if', () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500)
})
it('list-items-3', async () => {
const length = 3;
const elements = await page.$$('.list-item')
expect(elements.length).toBe(length)
it('show-hide-switch', async () => {
const btn_view = await page.$('.view-click')
const elements1 = await page.$$('.hello')
expect(elements1.length).toBe(1)
await btn_view.tap()
await page.waitFor(50)
const elements2 = await page.$$('.hello')
expect(elements2.length).toBe(0)
await btn_view.tap()
await page.waitFor(50)
const elements3 = await page.$$('.hello')
expect(elements3.length).toBe(1)
})
})
})
\ No newline at end of file
<template>
<view class="page">
<view class="split-title">v-if</view>
<button @click="onShowOrHide">show/hide</button>
<view class="view-click" @click="onShowOrHide">show/hide</view>
<view class="hello" v-if="show">hello</view>
</view>
</template>
......
......@@ -6,6 +6,11 @@ describe('v-once', () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500)
})
it('list-items-3', async () => {
it('change-message', async () => {
const btn_change = await page.$('.view-click')
const messageText = await page.$('.v-once-message')
await btn_change.tap()
expect(await messageText.text()).toBe('message')
})
})
<template>
<view class="page">
<view class="split-title">v-once</view>
<view class="v-once" v-once>This will never change: {{msg}}</view>
<view>
<text class="v-once">This will never change:</text>
<text class="v-once-message" v-once>{{message}}</text>
</view>
<view class="view-click" @click="changeMessage">Change message</view>
</view>
</template>
......@@ -9,10 +13,13 @@
export default {
data() {
return {
msg: ''
message: 'message'
}
},
methods: {
changeMessage() {
this.message = Date.now().toString()
}
}
}
</script>
......
<template>
<view>
<slot :loading="loading" :error="message" />
<slot />
<!-- <slot :loading="loading" :error="message" /> -->
</view>
</template>
......
......@@ -6,6 +6,8 @@ describe('v-slot', () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500)
})
it('list-items-3', async () => {
it('default', async () => {
const defaultText = await page.$('.default')
expect(await defaultText.text()).toBe('loading')
})
})
<template>
<view class="page">
<view class="split-title">v-slot</view>
<!-- <counter v-slot:default="options">
{{options['loading']}}
</counter> -->
<counter class="default" v-slot:default>loading</counter>
</view>
</template>
<script lang="ts">
// import counter from "./counter.uvue"
import counter from "./counter.uvue"
export default {
// components: {
// counter
// },
components: {
counter
},
data() {
return {
}
......
......@@ -118,7 +118,7 @@
{
name: 'v-once',
url: 'v-once',
enable: true
enable: false
},
{
name: 'v-memo',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册