test(Panel): add demo test

This commit is contained in:
nemo-shen 2021-12-06 23:57:19 +08:00 committed by neverland
parent 46a4c7c4f2
commit bd9ce42f8d
8 changed files with 239 additions and 15 deletions

View File

@ -101,6 +101,7 @@
"van-notice-bar": "./dist/notice-bar/index",
"van-notify": "./dist/notify/index",
"van-panel": "./dist/panel/index",
"van-panel-demo": "./dist/panel/demo/index",
"van-popup": "./dist/popup/index",
"van-progress": "./dist/progress/index",
"van-radio": "./dist/radio/index",

View File

@ -1,15 +1 @@
<demo-block title="基础用法">
<van-panel title="标题" desc="描述信息" status="状态">
<view class="content">内容</view>
</van-panel>
</demo-block>
<demo-block title="高级用法">
<van-panel title="标题" desc="描述信息" status="状态" use-footer-slot>
<view class="content">内容</view>
<view slot="footer" class="footer">
<van-button size="small" class="demo-margin-right">按钮</van-button>
<van-button size="small" type="danger">按钮</van-button>
</view>
</van-panel>
</demo-block>
<van-panel-demo />

View File

@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"van-panel": "../../panel/index",
"van-button": "../../button/index",
"demo-block": "../../../example/components/demo-block/index"
}
}

View File

@ -0,0 +1,5 @@
import { VantComponent } from '../../common/component';
VantComponent({
data: {},
});

View File

@ -0,0 +1,15 @@
<demo-block title="基础用法">
<van-panel title="标题" desc="描述信息" status="状态">
<view class="content">内容</view>
</van-panel>
</demo-block>
<demo-block title="高级用法">
<van-panel title="标题" desc="描述信息" status="状态" use-footer-slot>
<view class="content">内容</view>
<view slot="footer" class="footer">
<van-button size="small" class="demo-margin-right">按钮</van-button>
<van-button size="small" type="danger">按钮</van-button>
</view>
</van-panel>
</demo-block>

View File

@ -0,0 +1,198 @@
// 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 "
>
<wx-view
class="demo-block__title"
>
基础用法
</wx-view>
<van-panel>
<wx-view
class="van-panel van-hairline--top-bottom custom-class"
>
<van-cell
customClass="header-class"
valueClass="van-panel__header-value"
>
<wx-view
class="custom-class van-cell"
hoverClass="van-cell--hover hover-class"
hoverStayTime="70"
style=""
bind:tap="onClick"
>
<wx-view
class="van-cell__title title-class"
style=""
>
标题
<wx-view
class="van-cell__label label-class"
>
描述信息
</wx-view>
</wx-view>
<wx-view
class="van-cell__value value-class"
>
状态
</wx-view>
</wx-view>
</van-cell>
<wx-view
class="van-panel__content"
>
<wx-view
class="content"
>
内容
</wx-view>
</wx-view>
<wx-view
class="van-panel__footer van-hairline--top footer-class"
/>
</wx-view>
</van-panel>
</wx-view>
</demo-block>
<demo-block>
<wx-view
class="custom-class demo-block van-clearfix "
>
<wx-view
class="demo-block__title"
>
高级用法
</wx-view>
<van-panel
useFooterSlot="{{true}}"
>
<wx-view
class="van-panel van-hairline--top-bottom custom-class"
>
<van-cell
customClass="header-class"
valueClass="van-panel__header-value"
>
<wx-view
class="custom-class van-cell"
hoverClass="van-cell--hover hover-class"
hoverStayTime="70"
style=""
bind:tap="onClick"
>
<wx-view
class="van-cell__title title-class"
style=""
>
标题
<wx-view
class="van-cell__label label-class"
>
描述信息
</wx-view>
</wx-view>
<wx-view
class="van-cell__value value-class"
>
状态
</wx-view>
</wx-view>
</van-cell>
<wx-view
class="van-panel__content"
>
<wx-view
class="content"
>
内容
</wx-view>
</wx-view>
<wx-view
class="van-panel__footer van-hairline--top footer-class"
>
<wx-view
class="footer"
slot="footer"
>
<van-button
class="demo-margin-right"
>
<wx-button
appParameter=""
ariaLabel=""
businessId="{{0}}"
class="custom-class van-button van-button--default van-button--small "
data-detail="{{null}}"
formType=""
hoverClass="van-button--active hover-class"
id=""
lang=""
openType=""
sendMessageImg=""
sendMessagePath=""
sendMessageTitle=""
sessionFrom=""
showMessageCard="{{false}}"
style=""
bind:contact="onContact"
bind:error="onError"
bind:getphonenumber="onGetPhoneNumber"
bind:getuserinfo="onGetUserInfo"
bind:launchapp="onLaunchApp"
bind:opensetting="onOpenSetting"
bind:tap="onClick"
>
<wx-view
class="van-button__text"
>
按钮
</wx-view>
</wx-button>
</van-button>
<van-button>
<wx-button
appParameter=""
ariaLabel=""
businessId="{{0}}"
class="custom-class van-button van-button--danger van-button--small "
data-detail="{{null}}"
formType=""
hoverClass="van-button--active hover-class"
id=""
lang=""
openType=""
sendMessageImg=""
sendMessagePath=""
sendMessageTitle=""
sessionFrom=""
showMessageCard="{{false}}"
style=""
bind:contact="onContact"
bind:error="onError"
bind:getphonenumber="onGetPhoneNumber"
bind:getuserinfo="onGetUserInfo"
bind:launchapp="onLaunchApp"
bind:opensetting="onOpenSetting"
bind:tap="onClick"
>
<wx-view
class="van-button__text"
>
按钮
</wx-view>
</wx-button>
</van-button>
</wx-view>
</wx-view>
</wx-view>
</van-panel>
</wx-view>
</demo-block>
</main>
`;

View 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();
});