test(Divider): add demo test

This commit is contained in:
nemo-shen 2021-12-02 13:43:36 +08:00 committed by neverland
parent 03ee861ca6
commit 75eec05604
8 changed files with 144 additions and 20 deletions

View File

@ -83,6 +83,7 @@
"van-dialog": "./dist/dialog/index",
"van-dialog-demo": "./dist/dialog/demo/index",
"van-divider": "./dist/divider/index",
"van-divider-demo": "./dist/divider/demo/index",
"van-empty": "./dist/empty/index",
"van-field": "./dist/field/index",
"van-goods-action": "./dist/goods-action/index",

View File

@ -1,17 +1 @@
<demo-block custom-class="white" title="基础用法" padding>
<van-divider />
</demo-block>
<demo-block custom-class="white" title="内容位置" padding>
<van-divider content-position="center">文本</van-divider>
<van-divider content-position="left">文本</van-divider>
<van-divider content-position="right">文本</van-divider>
</demo-block>
<demo-block custom-class="white" title="虚线" padding>
<van-divider dashed />
</demo-block>
<demo-block custom-class="white" title="自定义样式" padding>
<van-divider content-position="center" custom-style="color: #1989fa;border-color: #1989fa;font-size: 18px;">文本</van-divider>
</demo-block>
<van-divider-demo />

View File

@ -1,3 +0,0 @@
page {
background-color: white;
}

View File

@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"van-divider": "../../divider/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,17 @@
<demo-block custom-class="white" title="基础用法" padding>
<van-divider />
</demo-block>
<demo-block custom-class="white" title="内容位置" padding>
<van-divider content-position="center">文本</van-divider>
<van-divider content-position="left">文本</van-divider>
<van-divider content-position="right">文本</van-divider>
</demo-block>
<demo-block custom-class="white" title="虚线" padding>
<van-divider dashed />
</demo-block>
<demo-block custom-class="white" title="自定义样式" padding>
<van-divider content-position="center" custom-style="color: #1989fa;border-color: #1989fa;font-size: 18px;">文本</van-divider>
</demo-block>

View File

@ -0,0 +1,102 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`should render demo and match snapshot 1`] = `
<main>
<demo-block
customClass="white"
>
<wx-view
class="custom-class demo-block van-clearfix demo-block--padding"
>
<wx-view
class="demo-block__title"
>
基础用法
</wx-view>
<van-divider>
<wx-view
class="custom-class van-divider"
style=""
/>
</van-divider>
</wx-view>
</demo-block>
<demo-block
customClass="white"
>
<wx-view
class="custom-class demo-block van-clearfix demo-block--padding"
>
<wx-view
class="demo-block__title"
>
内容位置
</wx-view>
<van-divider>
<wx-view
class="custom-class van-divider van-divider--center"
style=""
>
文本
</wx-view>
</van-divider>
<van-divider>
<wx-view
class="custom-class van-divider van-divider--left"
style=""
>
文本
</wx-view>
</van-divider>
<van-divider>
<wx-view
class="custom-class van-divider van-divider--right"
style=""
>
文本
</wx-view>
</van-divider>
</wx-view>
</demo-block>
<demo-block
customClass="white"
>
<wx-view
class="custom-class demo-block van-clearfix demo-block--padding"
>
<wx-view
class="demo-block__title"
>
虚线
</wx-view>
<van-divider>
<wx-view
class="custom-class van-divider van-divider--dashed"
style=""
/>
</van-divider>
</wx-view>
</demo-block>
<demo-block
customClass="white"
>
<wx-view
class="custom-class demo-block van-clearfix demo-block--padding"
>
<wx-view
class="demo-block__title"
>
自定义样式
</wx-view>
<van-divider>
<wx-view
class="custom-class van-divider van-divider--center"
style=";color: #1989fa;border-color: #1989fa;font-size: 18px;"
>
文本
</wx-view>
</van-divider>
</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();
});