mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
test(Card): add demo test
This commit is contained in:
parent
ff4299b124
commit
e14ca0b257
@ -70,6 +70,7 @@
|
|||||||
"van-button": "./dist/button/index",
|
"van-button": "./dist/button/index",
|
||||||
"van-button-demo": "./dist/button/demo/index",
|
"van-button-demo": "./dist/button/demo/index",
|
||||||
"van-card": "./dist/card/index",
|
"van-card": "./dist/card/index",
|
||||||
|
"van-card-demo": "./dist/card/demo/index",
|
||||||
"van-cell": "./dist/cell/index",
|
"van-cell": "./dist/cell/index",
|
||||||
"van-cell-group": "./dist/cell-group/index",
|
"van-cell-group": "./dist/cell-group/index",
|
||||||
"van-checkbox": "./dist/checkbox/index",
|
"van-checkbox": "./dist/checkbox/index",
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
import Page from '../../common/page';
|
import Page from '../../common/page';
|
||||||
|
|
||||||
Page({
|
Page();
|
||||||
data: {
|
|
||||||
imageURL: 'https://img.yzcdn.cn/upload_files/2017/07/02/af5b9f44deaeb68000d7e4a711160c53.jpg'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
@ -1,32 +1 @@
|
|||||||
<view class="container">
|
<van-card-demo />
|
||||||
<demo-block title="基础用法">
|
|
||||||
<van-card
|
|
||||||
num="2"
|
|
||||||
price="2.00"
|
|
||||||
desc="描述信息"
|
|
||||||
title="2018秋冬新款男士休闲时尚军绿飞行夹克秋冬新款男"
|
|
||||||
thumb="{{ imageURL }}"
|
|
||||||
/>
|
|
||||||
</demo-block>
|
|
||||||
|
|
||||||
<demo-block title="高级用法">
|
|
||||||
<van-card
|
|
||||||
num="2"
|
|
||||||
tag="标签"
|
|
||||||
price="2.00"
|
|
||||||
origin-price="10.00"
|
|
||||||
desc="描述信息"
|
|
||||||
title="2018秋冬新款男士休闲时尚军绿飞行夹克秋冬新款男"
|
|
||||||
thumb="{{ imageURL }}"
|
|
||||||
>
|
|
||||||
<view slot="tags">
|
|
||||||
<van-tag plain type="danger" custom-class="tag">标签1</van-tag>
|
|
||||||
<van-tag plain type="danger">标签2</van-tag>
|
|
||||||
</view>
|
|
||||||
<view slot="footer" class="van-card__footer">
|
|
||||||
<van-button size="mini" round custom-class="button">按钮</van-button>
|
|
||||||
<van-button size="mini" round>按钮</van-button>
|
|
||||||
</view>
|
|
||||||
</van-card>
|
|
||||||
</demo-block>
|
|
||||||
</view>
|
|
||||||
|
7
packages/card/demo/index.json
Normal file
7
packages/card/demo/index.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {
|
||||||
|
"van-card": "../../card/index",
|
||||||
|
"demo-block": "../../../example/components/demo-block/index"
|
||||||
|
}
|
||||||
|
}
|
8
packages/card/demo/index.ts
Normal file
8
packages/card/demo/index.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { VantComponent } from '../../common/component';
|
||||||
|
|
||||||
|
VantComponent({
|
||||||
|
data: {
|
||||||
|
imageURL:
|
||||||
|
'https://img.yzcdn.cn/upload_files/2017/07/02/af5b9f44deaeb68000d7e4a711160c53.jpg',
|
||||||
|
},
|
||||||
|
});
|
32
packages/card/demo/index.wxml
Normal file
32
packages/card/demo/index.wxml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<view class="container">
|
||||||
|
<demo-block title="基础用法">
|
||||||
|
<van-card
|
||||||
|
num="2"
|
||||||
|
price="2.00"
|
||||||
|
desc="描述信息"
|
||||||
|
title="2018秋冬新款男士休闲时尚军绿飞行夹克秋冬新款男"
|
||||||
|
thumb="{{ imageURL }}"
|
||||||
|
/>
|
||||||
|
</demo-block>
|
||||||
|
|
||||||
|
<demo-block title="高级用法">
|
||||||
|
<van-card
|
||||||
|
num="2"
|
||||||
|
tag="标签"
|
||||||
|
price="2.00"
|
||||||
|
origin-price="10.00"
|
||||||
|
desc="描述信息"
|
||||||
|
title="2018秋冬新款男士休闲时尚军绿飞行夹克秋冬新款男"
|
||||||
|
thumb="{{ imageURL }}"
|
||||||
|
>
|
||||||
|
<view slot="tags">
|
||||||
|
<van-tag plain type="danger" custom-class="tag">标签1</van-tag>
|
||||||
|
<van-tag plain type="danger">标签2</van-tag>
|
||||||
|
</view>
|
||||||
|
<view slot="footer" class="van-card__footer">
|
||||||
|
<van-button size="mini" round custom-class="button">按钮</van-button>
|
||||||
|
<van-button size="mini" round>按钮</van-button>
|
||||||
|
</view>
|
||||||
|
</van-card>
|
||||||
|
</demo-block>
|
||||||
|
</view>
|
217
packages/card/test/__snapshots__/demo.spec.ts.snap
Normal file
217
packages/card/test/__snapshots__/demo.spec.ts.snap
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`should render demo and match snapshot 1`] = `
|
||||||
|
<main>
|
||||||
|
<wx-view
|
||||||
|
class="container"
|
||||||
|
>
|
||||||
|
<demo-block>
|
||||||
|
<wx-view
|
||||||
|
class="custom-class demo-block van-clearfix "
|
||||||
|
>
|
||||||
|
<wx-view
|
||||||
|
class="demo-block__title"
|
||||||
|
>
|
||||||
|
基础用法
|
||||||
|
</wx-view>
|
||||||
|
<van-card>
|
||||||
|
<wx-view
|
||||||
|
class="custom-class van-card"
|
||||||
|
>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__header"
|
||||||
|
>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__thumb"
|
||||||
|
bind:tap="onClickThumb"
|
||||||
|
>
|
||||||
|
<wx-image
|
||||||
|
class="van-card__img thumb-class"
|
||||||
|
lazyLoad="{{false}}"
|
||||||
|
mode="aspectFit"
|
||||||
|
src="https://img.yzcdn.cn/upload_files/2017/07/02/af5b9f44deaeb68000d7e4a711160c53.jpg"
|
||||||
|
/>
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__content van-card__content"
|
||||||
|
>
|
||||||
|
<wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__title title-class"
|
||||||
|
>
|
||||||
|
2018秋冬新款男士休闲时尚军绿飞行夹克秋冬新款男
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__desc desc-class"
|
||||||
|
>
|
||||||
|
描述信息
|
||||||
|
</wx-view>
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__bottom"
|
||||||
|
>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__price price-class"
|
||||||
|
>
|
||||||
|
<wx-text>
|
||||||
|
¥
|
||||||
|
</wx-text>
|
||||||
|
<wx-text
|
||||||
|
class="van-card__price-integer"
|
||||||
|
>
|
||||||
|
2
|
||||||
|
</wx-text>
|
||||||
|
<wx-text
|
||||||
|
class="van-card__price-decimal"
|
||||||
|
>
|
||||||
|
.00
|
||||||
|
</wx-text>
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__num num-class"
|
||||||
|
>
|
||||||
|
x 2
|
||||||
|
</wx-view>
|
||||||
|
</wx-view>
|
||||||
|
</wx-view>
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__footer"
|
||||||
|
/>
|
||||||
|
</wx-view>
|
||||||
|
</van-card>
|
||||||
|
</wx-view>
|
||||||
|
</demo-block>
|
||||||
|
<demo-block>
|
||||||
|
<wx-view
|
||||||
|
class="custom-class demo-block van-clearfix "
|
||||||
|
>
|
||||||
|
<wx-view
|
||||||
|
class="demo-block__title"
|
||||||
|
>
|
||||||
|
高级用法
|
||||||
|
</wx-view>
|
||||||
|
<van-card>
|
||||||
|
<wx-view
|
||||||
|
class="custom-class van-card"
|
||||||
|
>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__header"
|
||||||
|
>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__thumb"
|
||||||
|
bind:tap="onClickThumb"
|
||||||
|
>
|
||||||
|
<wx-image
|
||||||
|
class="van-card__img thumb-class"
|
||||||
|
lazyLoad="{{false}}"
|
||||||
|
mode="aspectFit"
|
||||||
|
src="https://img.yzcdn.cn/upload_files/2017/07/02/af5b9f44deaeb68000d7e4a711160c53.jpg"
|
||||||
|
/>
|
||||||
|
<van-tag
|
||||||
|
customClass="van-card__tag"
|
||||||
|
>
|
||||||
|
<wx-view
|
||||||
|
class="custom-class van-tag van-tag--danger van-tag--mark"
|
||||||
|
style=""
|
||||||
|
>
|
||||||
|
|
||||||
|
标签
|
||||||
|
|
||||||
|
</wx-view>
|
||||||
|
</van-tag>
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__content van-card__content"
|
||||||
|
>
|
||||||
|
<wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__title title-class"
|
||||||
|
>
|
||||||
|
2018秋冬新款男士休闲时尚军绿飞行夹克秋冬新款男
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__desc desc-class"
|
||||||
|
>
|
||||||
|
描述信息
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
slot="tags"
|
||||||
|
>
|
||||||
|
<van-tag
|
||||||
|
customClass="tag"
|
||||||
|
plain="{{true}}"
|
||||||
|
type="danger"
|
||||||
|
>
|
||||||
|
标签1
|
||||||
|
</van-tag>
|
||||||
|
<van-tag
|
||||||
|
plain="{{true}}"
|
||||||
|
type="danger"
|
||||||
|
>
|
||||||
|
标签2
|
||||||
|
</van-tag>
|
||||||
|
</wx-view>
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__bottom"
|
||||||
|
>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__price price-class"
|
||||||
|
>
|
||||||
|
<wx-text>
|
||||||
|
¥
|
||||||
|
</wx-text>
|
||||||
|
<wx-text
|
||||||
|
class="van-card__price-integer"
|
||||||
|
>
|
||||||
|
2
|
||||||
|
</wx-text>
|
||||||
|
<wx-text
|
||||||
|
class="van-card__price-decimal"
|
||||||
|
>
|
||||||
|
.00
|
||||||
|
</wx-text>
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__origin-price origin-price-class"
|
||||||
|
>
|
||||||
|
¥ 10.00
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__num num-class"
|
||||||
|
>
|
||||||
|
x 2
|
||||||
|
</wx-view>
|
||||||
|
</wx-view>
|
||||||
|
</wx-view>
|
||||||
|
</wx-view>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__footer"
|
||||||
|
>
|
||||||
|
<wx-view
|
||||||
|
class="van-card__footer"
|
||||||
|
slot="footer"
|
||||||
|
>
|
||||||
|
<van-button
|
||||||
|
customClass="button"
|
||||||
|
round="{{true}}"
|
||||||
|
size="mini"
|
||||||
|
>
|
||||||
|
按钮
|
||||||
|
</van-button>
|
||||||
|
<van-button
|
||||||
|
round="{{true}}"
|
||||||
|
size="mini"
|
||||||
|
>
|
||||||
|
按钮
|
||||||
|
</van-button>
|
||||||
|
</wx-view>
|
||||||
|
</wx-view>
|
||||||
|
</wx-view>
|
||||||
|
</van-card>
|
||||||
|
</wx-view>
|
||||||
|
</demo-block>
|
||||||
|
</wx-view>
|
||||||
|
</main>
|
||||||
|
`;
|
11
packages/card/test/demo.spec.ts
Normal file
11
packages/card/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