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

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

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