mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
test(Transition): add demo test
This commit is contained in:
parent
e90eae2a9f
commit
390eab8d0d
@ -146,6 +146,7 @@
|
||||
"van-toast": "./dist/toast/index",
|
||||
"van-toast-demo": "./dist/toast/demo/index",
|
||||
"van-transition": "./dist/transition/index",
|
||||
"van-transition-demo": "./dist/transition/demo/index",
|
||||
"van-tree-select": "./dist/tree-select/index",
|
||||
"van-tree-select-demo": "./dist/tree-select/demo/index",
|
||||
"van-datetime-picker": "./dist/datetime-picker/index",
|
||||
|
@ -1,84 +1,3 @@
|
||||
import Page from '../../common/page';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
show: false,
|
||||
name: 'fade',
|
||||
showCustom: false
|
||||
},
|
||||
|
||||
onClickFade() {
|
||||
this.trigger('fade');
|
||||
},
|
||||
|
||||
onClickFadeUp() {
|
||||
this.trigger('fade-up');
|
||||
},
|
||||
|
||||
onClickFadeDown() {
|
||||
this.trigger('fade-down');
|
||||
},
|
||||
|
||||
onClickFadeLeft() {
|
||||
this.trigger('fade-left');
|
||||
},
|
||||
|
||||
onClickFadeRight() {
|
||||
this.trigger('fade-right');
|
||||
},
|
||||
|
||||
onClickSlideUp() {
|
||||
this.trigger('slide-up');
|
||||
},
|
||||
|
||||
onClickSlideDown() {
|
||||
this.trigger('slide-down');
|
||||
},
|
||||
|
||||
onClickSlideLeft() {
|
||||
this.trigger('slide-left');
|
||||
},
|
||||
|
||||
onClickSlideRight() {
|
||||
this.trigger('slide-right');
|
||||
},
|
||||
|
||||
trigger(name) {
|
||||
this.setData({ name, show: true });
|
||||
setTimeout(() => {
|
||||
this.setData({ show: false });
|
||||
}, 500);
|
||||
},
|
||||
|
||||
onClickCustom() {
|
||||
this.setData({ showCustom: true });
|
||||
|
||||
setTimeout(() => {
|
||||
this.setData({ showCustom: false });
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
onBeforeEnter() {
|
||||
console.log('before enter');
|
||||
},
|
||||
|
||||
onEnter() {
|
||||
console.log('enter');
|
||||
},
|
||||
|
||||
onAfterEnter() {
|
||||
console.log('after enter');
|
||||
},
|
||||
|
||||
onBeforeLeave() {
|
||||
console.log('before leave');
|
||||
},
|
||||
|
||||
onLeave() {
|
||||
console.log('leave');
|
||||
},
|
||||
|
||||
onAfterLeave() {
|
||||
console.log('after leave');
|
||||
},
|
||||
});
|
||||
Page();
|
||||
|
@ -1,35 +1 @@
|
||||
<demo-block title="基础用法" padding>
|
||||
<van-cell title="Fade" bind:click="onClickFade" is-link />
|
||||
<van-cell title="Fade Up" bind:click="onClickFadeUp" is-link />
|
||||
<van-cell title="Fade Down" bind:click="onClickFadeDown" is-link />
|
||||
<van-cell title="Fade Left" bind:click="onClickFadeLeft" is-link />
|
||||
<van-cell title="Fade Right" bind:click="onClickFadeRight" is-link />
|
||||
<van-cell title="Slide Up" bind:click="onClickSlideUp" is-link />
|
||||
<van-cell title="Slide Down" bind:click="onClickSlideDown" is-link />
|
||||
<van-cell title="Slide Left" bind:click="onClickSlideLeft" is-link />
|
||||
<van-cell title="Slide Right" bind:click="onClickSlideRight" is-link />
|
||||
<van-cell title="Custom" bind:click="onClickCustom" is-link />
|
||||
|
||||
<van-transition
|
||||
show="{{ show }}"
|
||||
name="{{ name }}"
|
||||
custom-class="block"
|
||||
/>
|
||||
|
||||
<van-transition
|
||||
show="{{ showCustom }}"
|
||||
name=""
|
||||
duration="{{ { enter: 300, leave: 1000 } }}"
|
||||
custom-class="block"
|
||||
enter-class="van-enter-class"
|
||||
enter-active-class="van-enter-active-class"
|
||||
leave-active-class="van-leave-active-class"
|
||||
leave-to-class="van-leave-to-class"
|
||||
bind:before-enter="onBeforeEnter"
|
||||
bind:enter="onEnter"
|
||||
bind:after-enter="onAfterEnter"
|
||||
bind:before-leave="onBeforeLeave"
|
||||
bind:leave="onLeave"
|
||||
bind:after-leave="onAfterLeave"
|
||||
/>
|
||||
</demo-block>
|
||||
<van-transition-demo />
|
||||
|
8
packages/transition/demo/index.json
Normal file
8
packages/transition/demo/index.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-cell": "../../cell/index",
|
||||
"van-transition": "../../transition/index",
|
||||
"demo-block": "../../../example/components/demo-block/index"
|
||||
}
|
||||
}
|
86
packages/transition/demo/index.ts
Normal file
86
packages/transition/demo/index.ts
Normal file
@ -0,0 +1,86 @@
|
||||
import { VantComponent } from '../../common/component';
|
||||
|
||||
VantComponent({
|
||||
data: {
|
||||
show: false,
|
||||
name: 'fade',
|
||||
showCustom: false,
|
||||
},
|
||||
|
||||
methods: {
|
||||
onClickFade() {
|
||||
this.trigger('fade');
|
||||
},
|
||||
|
||||
onClickFadeUp() {
|
||||
this.trigger('fade-up');
|
||||
},
|
||||
|
||||
onClickFadeDown() {
|
||||
this.trigger('fade-down');
|
||||
},
|
||||
|
||||
onClickFadeLeft() {
|
||||
this.trigger('fade-left');
|
||||
},
|
||||
|
||||
onClickFadeRight() {
|
||||
this.trigger('fade-right');
|
||||
},
|
||||
|
||||
onClickSlideUp() {
|
||||
this.trigger('slide-up');
|
||||
},
|
||||
|
||||
onClickSlideDown() {
|
||||
this.trigger('slide-down');
|
||||
},
|
||||
|
||||
onClickSlideLeft() {
|
||||
this.trigger('slide-left');
|
||||
},
|
||||
|
||||
onClickSlideRight() {
|
||||
this.trigger('slide-right');
|
||||
},
|
||||
|
||||
trigger(name) {
|
||||
this.setData({ name, show: true });
|
||||
setTimeout(() => {
|
||||
this.setData({ show: false });
|
||||
}, 500);
|
||||
},
|
||||
|
||||
onClickCustom() {
|
||||
this.setData({ showCustom: true });
|
||||
|
||||
setTimeout(() => {
|
||||
this.setData({ showCustom: false });
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
onBeforeEnter() {
|
||||
console.log('before enter');
|
||||
},
|
||||
|
||||
onEnter() {
|
||||
console.log('enter');
|
||||
},
|
||||
|
||||
onAfterEnter() {
|
||||
console.log('after enter');
|
||||
},
|
||||
|
||||
onBeforeLeave() {
|
||||
console.log('before leave');
|
||||
},
|
||||
|
||||
onLeave() {
|
||||
console.log('leave');
|
||||
},
|
||||
|
||||
onAfterLeave() {
|
||||
console.log('after leave');
|
||||
},
|
||||
},
|
||||
});
|
35
packages/transition/demo/index.wxml
Normal file
35
packages/transition/demo/index.wxml
Normal file
@ -0,0 +1,35 @@
|
||||
<demo-block title="基础用法" padding>
|
||||
<van-cell title="Fade" bind:click="onClickFade" is-link />
|
||||
<van-cell title="Fade Up" bind:click="onClickFadeUp" is-link />
|
||||
<van-cell title="Fade Down" bind:click="onClickFadeDown" is-link />
|
||||
<van-cell title="Fade Left" bind:click="onClickFadeLeft" is-link />
|
||||
<van-cell title="Fade Right" bind:click="onClickFadeRight" is-link />
|
||||
<van-cell title="Slide Up" bind:click="onClickSlideUp" is-link />
|
||||
<van-cell title="Slide Down" bind:click="onClickSlideDown" is-link />
|
||||
<van-cell title="Slide Left" bind:click="onClickSlideLeft" is-link />
|
||||
<van-cell title="Slide Right" bind:click="onClickSlideRight" is-link />
|
||||
<van-cell title="Custom" bind:click="onClickCustom" is-link />
|
||||
|
||||
<van-transition
|
||||
show="{{ show }}"
|
||||
name="{{ name }}"
|
||||
custom-class="block"
|
||||
/>
|
||||
|
||||
<van-transition
|
||||
show="{{ showCustom }}"
|
||||
name=""
|
||||
duration="{{ { enter: 300, leave: 1000 } }}"
|
||||
custom-class="block"
|
||||
enter-class="van-enter-class"
|
||||
enter-active-class="van-enter-active-class"
|
||||
leave-active-class="van-leave-active-class"
|
||||
leave-to-class="van-leave-to-class"
|
||||
bind:before-enter="onBeforeEnter"
|
||||
bind:enter="onEnter"
|
||||
bind:after-enter="onAfterEnter"
|
||||
bind:before-leave="onBeforeLeave"
|
||||
bind:leave="onLeave"
|
||||
bind:after-leave="onAfterLeave"
|
||||
/>
|
||||
</demo-block>
|
343
packages/transition/test/__snapshots__/demo.spec.ts.snap
Normal file
343
packages/transition/test/__snapshots__/demo.spec.ts.snap
Normal file
@ -0,0 +1,343 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`should render demo and match snapshot 1`] = `
|
||||
<main>
|
||||
<demo-block>
|
||||
<wx-view
|
||||
class="custom-class demo-block van-clearfix demo-block--padding"
|
||||
>
|
||||
<wx-view
|
||||
class="demo-block__title"
|
||||
>
|
||||
基础用法
|
||||
</wx-view>
|
||||
<van-cell
|
||||
bind:click="onClickFade"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
hoverClass="van-cell--hover hover-class"
|
||||
hoverStayTime="70"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<wx-view
|
||||
class="van-cell__title title-class"
|
||||
style=""
|
||||
>
|
||||
Fade
|
||||
</wx-view>
|
||||
<wx-view
|
||||
class="van-cell__value value-class"
|
||||
/>
|
||||
<van-icon
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
customClass="van-cell__right-icon"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-icon van-icon-arrow"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
/>
|
||||
</van-icon>
|
||||
</wx-view>
|
||||
</van-cell>
|
||||
<van-cell
|
||||
bind:click="onClickFadeUp"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
hoverClass="van-cell--hover hover-class"
|
||||
hoverStayTime="70"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<wx-view
|
||||
class="van-cell__title title-class"
|
||||
style=""
|
||||
>
|
||||
Fade Up
|
||||
</wx-view>
|
||||
<wx-view
|
||||
class="van-cell__value value-class"
|
||||
/>
|
||||
<van-icon
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
customClass="van-cell__right-icon"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-icon van-icon-arrow"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
/>
|
||||
</van-icon>
|
||||
</wx-view>
|
||||
</van-cell>
|
||||
<van-cell
|
||||
bind:click="onClickFadeDown"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
hoverClass="van-cell--hover hover-class"
|
||||
hoverStayTime="70"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<wx-view
|
||||
class="van-cell__title title-class"
|
||||
style=""
|
||||
>
|
||||
Fade Down
|
||||
</wx-view>
|
||||
<wx-view
|
||||
class="van-cell__value value-class"
|
||||
/>
|
||||
<van-icon
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
customClass="van-cell__right-icon"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-icon van-icon-arrow"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
/>
|
||||
</van-icon>
|
||||
</wx-view>
|
||||
</van-cell>
|
||||
<van-cell
|
||||
bind:click="onClickFadeLeft"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
hoverClass="van-cell--hover hover-class"
|
||||
hoverStayTime="70"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<wx-view
|
||||
class="van-cell__title title-class"
|
||||
style=""
|
||||
>
|
||||
Fade Left
|
||||
</wx-view>
|
||||
<wx-view
|
||||
class="van-cell__value value-class"
|
||||
/>
|
||||
<van-icon
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
customClass="van-cell__right-icon"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-icon van-icon-arrow"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
/>
|
||||
</van-icon>
|
||||
</wx-view>
|
||||
</van-cell>
|
||||
<van-cell
|
||||
bind:click="onClickFadeRight"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
hoverClass="van-cell--hover hover-class"
|
||||
hoverStayTime="70"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<wx-view
|
||||
class="van-cell__title title-class"
|
||||
style=""
|
||||
>
|
||||
Fade Right
|
||||
</wx-view>
|
||||
<wx-view
|
||||
class="van-cell__value value-class"
|
||||
/>
|
||||
<van-icon
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
customClass="van-cell__right-icon"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-icon van-icon-arrow"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
/>
|
||||
</van-icon>
|
||||
</wx-view>
|
||||
</van-cell>
|
||||
<van-cell
|
||||
bind:click="onClickSlideUp"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
hoverClass="van-cell--hover hover-class"
|
||||
hoverStayTime="70"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<wx-view
|
||||
class="van-cell__title title-class"
|
||||
style=""
|
||||
>
|
||||
Slide Up
|
||||
</wx-view>
|
||||
<wx-view
|
||||
class="van-cell__value value-class"
|
||||
/>
|
||||
<van-icon
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
customClass="van-cell__right-icon"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-icon van-icon-arrow"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
/>
|
||||
</van-icon>
|
||||
</wx-view>
|
||||
</van-cell>
|
||||
<van-cell
|
||||
bind:click="onClickSlideDown"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
hoverClass="van-cell--hover hover-class"
|
||||
hoverStayTime="70"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<wx-view
|
||||
class="van-cell__title title-class"
|
||||
style=""
|
||||
>
|
||||
Slide Down
|
||||
</wx-view>
|
||||
<wx-view
|
||||
class="van-cell__value value-class"
|
||||
/>
|
||||
<van-icon
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
customClass="van-cell__right-icon"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-icon van-icon-arrow"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
/>
|
||||
</van-icon>
|
||||
</wx-view>
|
||||
</van-cell>
|
||||
<van-cell
|
||||
bind:click="onClickSlideLeft"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
hoverClass="van-cell--hover hover-class"
|
||||
hoverStayTime="70"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<wx-view
|
||||
class="van-cell__title title-class"
|
||||
style=""
|
||||
>
|
||||
Slide Left
|
||||
</wx-view>
|
||||
<wx-view
|
||||
class="van-cell__value value-class"
|
||||
/>
|
||||
<van-icon
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
customClass="van-cell__right-icon"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-icon van-icon-arrow"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
/>
|
||||
</van-icon>
|
||||
</wx-view>
|
||||
</van-cell>
|
||||
<van-cell
|
||||
bind:click="onClickSlideRight"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
hoverClass="van-cell--hover hover-class"
|
||||
hoverStayTime="70"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<wx-view
|
||||
class="van-cell__title title-class"
|
||||
style=""
|
||||
>
|
||||
Slide Right
|
||||
</wx-view>
|
||||
<wx-view
|
||||
class="van-cell__value value-class"
|
||||
/>
|
||||
<van-icon
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
customClass="van-cell__right-icon"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-icon van-icon-arrow"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
/>
|
||||
</van-icon>
|
||||
</wx-view>
|
||||
</van-cell>
|
||||
<van-cell
|
||||
bind:click="onClickCustom"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-cell van-cell--clickable"
|
||||
hoverClass="van-cell--hover hover-class"
|
||||
hoverStayTime="70"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<wx-view
|
||||
class="van-cell__title title-class"
|
||||
style=""
|
||||
>
|
||||
Custom
|
||||
</wx-view>
|
||||
<wx-view
|
||||
class="van-cell__value value-class"
|
||||
/>
|
||||
<van-icon
|
||||
class="van-cell__right-icon-wrap right-icon-class"
|
||||
customClass="van-cell__right-icon"
|
||||
>
|
||||
<wx-view
|
||||
class="custom-class van-icon van-icon-arrow"
|
||||
style=""
|
||||
bind:tap="onClick"
|
||||
/>
|
||||
</van-icon>
|
||||
</wx-view>
|
||||
</van-cell>
|
||||
<van-transition
|
||||
customClass="block"
|
||||
/>
|
||||
<van-transition
|
||||
customClass="block"
|
||||
enterActiveClass="van-enter-active-class"
|
||||
enterClass="van-enter-class"
|
||||
leaveActiveClass="van-leave-active-class"
|
||||
leaveToClass="van-leave-to-class"
|
||||
bind:after-enter="onAfterEnter"
|
||||
bind:after-leave="onAfterLeave"
|
||||
bind:before-enter="onBeforeEnter"
|
||||
bind:before-leave="onBeforeLeave"
|
||||
bind:enter="onEnter"
|
||||
bind:leave="onLeave"
|
||||
/>
|
||||
</wx-view>
|
||||
</demo-block>
|
||||
</main>
|
||||
`;
|
11
packages/transition/test/demo.spec.ts
Normal file
11
packages/transition/test/demo.spec.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import path from 'path';
|
||||
import simulate from 'miniprogram-simulate';
|
||||
|
||||
test('should render demo and match snapshot', () => {
|
||||
const id = simulate.load(path.resolve(__dirname, '../demo/index'), {
|
||||
rootPath: path.resolve(__dirname, '../../'),
|
||||
});
|
||||
const comp = simulate.render(id);
|
||||
comp.attach(document.createElement('parent-wrapper'));
|
||||
expect(comp.toJSON()).toMatchSnapshot();
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user