diff --git a/example/app.json b/example/app.json index 83334e49..98e3d1f3 100644 --- a/example/app.json +++ b/example/app.json @@ -129,7 +129,8 @@ "van-tabbar": "./dist/tabbar/index", "van-tabbar-demo": "./dist/tabbar/demo/index", "van-tabbar-item": "./dist/tabbar-item/index", - "van-tag": "./dist/tag/index", + "van-tag": "./dist/tag/index",packages/tag/demo/index.less, + "van-tag-demo": "./dist/tag/demo/index", "van-toast": "./dist/toast/index", "van-transition": "./dist/transition/index", "van-tree-select": "./dist/tree-select/index", diff --git a/example/pages/tag/index.js b/example/pages/tag/index.js index a9feed40..cc11dfda 100644 --- a/example/pages/tag/index.js +++ b/example/pages/tag/index.js @@ -1,16 +1,3 @@ import Page from '../../common/page'; -Page({ - data: { - show: { - success: true, - primary: true - } - }, - - onClose(event) { - this.setData({ - [`show.${event.target.id}`]: false - }); - } -}); +Page(); diff --git a/example/pages/tag/index.wxml b/example/pages/tag/index.wxml index 49df6246..ed48ac94 100644 --- a/example/pages/tag/index.wxml +++ b/example/pages/tag/index.wxml @@ -1,65 +1 @@ - - 标签 - 标签 - 标签 - 标签 - - - - 标签 - 标签 - 标签 - 标签 - - - - 标签 - 标签 - 标签 - 标签 - - - - 标签 - 标签 - 标签 - 标签 - - - - 标签 - 标签 - 标签 - 标签 - - - - 标签 - 标签 - 标签 - - - - 标签 - 标签 - + diff --git a/example/pages/tag/index.wxss b/example/pages/tag/index.wxss deleted file mode 100644 index 10416bfb..00000000 --- a/example/pages/tag/index.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/tag/index.wxss */ \ No newline at end of file diff --git a/packages/tabbar/test/__snapshots__/demo.spec.ts.snap b/packages/tabbar/test/__snapshots__/demo.spec.ts.snap new file mode 100644 index 00000000..2433e3ff --- /dev/null +++ b/packages/tabbar/test/__snapshots__/demo.spec.ts.snap @@ -0,0 +1,832 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render demo and match snapshot 1`] = ` +
+ + + + 基础用法 + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + 标签 + + + + + + + + + + + 通过名称匹配 + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + 标签 + + + + + + + + + + + 显示徽标 + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + + + + + 标签 + + + + + + + + + + + + 5 + + + + + 标签 + + + + + + + + + + + + 20 + + + + + 标签 + + + + + + + + + + + 自定义图标 + + + + + + + + + + 3 + + + + + + 自定义 + + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + 标签 + + + + + + + + + + + 自定义颜色 + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + 标签 + + + + + + + + + + + + + 标签 + + + + + + + + + + + 切换标签事件 + + + + + + + + + + + + + 标签1 + + + + + + + + + + + + + 标签2 + + + + + + + + + + + + + 标签3 + + + + + + + + + + + + + 标签4 + + + + + + + +
+`; diff --git a/packages/tag/demo/index.json b/packages/tag/demo/index.json new file mode 100644 index 00000000..a9a79b83 --- /dev/null +++ b/packages/tag/demo/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-tag": "../../tag/index", + "demo-block": "../../../example/components/demo-block/index" + } +} diff --git a/packages/tag/demo/index.ts b/packages/tag/demo/index.ts new file mode 100644 index 00000000..5e064a21 --- /dev/null +++ b/packages/tag/demo/index.ts @@ -0,0 +1,18 @@ +import { VantComponent } from '../../common/component'; + +VantComponent({ + data: { + show: { + success: true, + primary: true, + }, + }, + + methods: { + onClose(event) { + this.setData({ + [`show.${event.target.id}`]: false, + }); + }, + }, +}); diff --git a/packages/tag/demo/index.wxml b/packages/tag/demo/index.wxml new file mode 100644 index 00000000..4a9c8fe8 --- /dev/null +++ b/packages/tag/demo/index.wxml @@ -0,0 +1,65 @@ + + 标签 + 标签 + 标签 + 标签 + + + + 标签 + 标签 + 标签 + 标签 + + + + 标签 + 标签 + 标签 + 标签 + + + + 标签 + 标签 + 标签 + 标签 + + + + 标签 + 标签 + 标签 + 标签 + + + + 标签 + 标签 + 标签 + + + + 标签 + 标签 + diff --git a/packages/tag/test/__snapshots__/demo.spec.ts.snap b/packages/tag/test/__snapshots__/demo.spec.ts.snap new file mode 100644 index 00000000..f2f08fdd --- /dev/null +++ b/packages/tag/test/__snapshots__/demo.spec.ts.snap @@ -0,0 +1,357 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render demo and match snapshot 1`] = ` +
+ + + + 基础用法 + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + + + + 圆角样式 + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + + + + 标记样式 + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + + + + 空心样式 + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + + + + 自定义颜色 + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + + + + 标签大小 + + + + 标签 + + + + + 标签 + + + + + 标签 + + + + + + + + 可关闭标签 + + + + 标签 + + + + + + + + 标签 + + + + + + + +
+`; diff --git a/packages/tag/test/demo.spec.ts b/packages/tag/test/demo.spec.ts new file mode 100644 index 00000000..4c3798cb --- /dev/null +++ b/packages/tag/test/demo.spec.ts @@ -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(); +});