diff --git a/example/app.json b/example/app.json index bab31741..ccd15ebe 100644 --- a/example/app.json +++ b/example/app.json @@ -72,6 +72,7 @@ "van-card": "./dist/card/index", "van-card-demo": "./dist/card/demo/index", "van-cell": "./dist/cell/index", + "van-cell-demo": "./dist/cell/demo/index", "van-cell-group": "./dist/cell-group/index", "van-checkbox": "./dist/checkbox/index", "van-checkbox-group": "./dist/checkbox-group/index", diff --git a/example/pages/cell/index.wxml b/example/pages/cell/index.wxml index 72130cb3..93689ab5 100644 --- a/example/pages/cell/index.wxml +++ b/example/pages/cell/index.wxml @@ -1,97 +1 @@ - - - - - - - - - - - - - - - - - - - 描述信息 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 单元格 - 标签 - - - - - - - - - - + diff --git a/packages/cell/demo/index.json b/packages/cell/demo/index.json new file mode 100644 index 00000000..62f238b0 --- /dev/null +++ b/packages/cell/demo/index.json @@ -0,0 +1,10 @@ +{ + "component": true, + "usingComponents": { + "van-cell": "../../cell/index", + "van-cell-group": "../../cell-group/index", + "van-icon": "../../icon/index", + "van-tag": "../../tag/index", + "demo-block": "../../../example/components/demo-block/index" + } +} diff --git a/example/pages/cell/index.wxss b/packages/cell/demo/index.less similarity index 100% rename from example/pages/cell/index.wxss rename to packages/cell/demo/index.less diff --git a/packages/cell/demo/index.ts b/packages/cell/demo/index.ts new file mode 100644 index 00000000..a32755a5 --- /dev/null +++ b/packages/cell/demo/index.ts @@ -0,0 +1,5 @@ +import { VantComponent } from '../../common/component'; + +VantComponent({ + data: {}, +}); diff --git a/packages/cell/demo/index.wxml b/packages/cell/demo/index.wxml new file mode 100644 index 00000000..72130cb3 --- /dev/null +++ b/packages/cell/demo/index.wxml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + 描述信息 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 单元格 + 标签 + + + + + + + + + + diff --git a/packages/cell/test/__snapshots__/demo.spec.ts.snap b/packages/cell/test/__snapshots__/demo.spec.ts.snap new file mode 100644 index 00000000..3970018c --- /dev/null +++ b/packages/cell/test/__snapshots__/demo.spec.ts.snap @@ -0,0 +1,627 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render demo and match snapshot 1`] = ` +
+ + + + 基础用法 + + + + + + + 单元格 + + + 内容 + + + + + + + 单元格 + + 描述信息 + + + + 内容 + + + + + + + + + + + 卡片风格 + + + + + + + 单元格 + + + 内容 + + + + + + + 单元格 + + 描述信息 + + + + 内容 + + + + + + + + + + + 单元格大小 + + + + + + + 单元格 + + + 内容 + + + + + + + 单元格 + + + 描述信息 + + + + + 内容 + + + + + + + + + + + 展示图标 + + + + + + + + 单元格 + + + 内容 + + + + + + + + + 展示箭头 + + + + + 单元格 + + + + + + + + + + + 单元格 + + + 内容 + + + + + + + + + + 单元格 + + + 内容 + + + + + + + + + + + + 页面跳转 + + + + + 单元格 + + + + + + + + + + + 单元格 + + + + + + + + + + + + + 分组标题 + + + + + 分组 1 + + + + + + + 单元格 + + + 内容 + + + + + + + + + 分组 2 + + + + + + + 单元格 + + + 内容 + + + + + + + + + + + 使用插槽 + + + + + + + + + + 单元格 + + + + 标签 + + + + + + 内容 + + + + + + + + + + 单元格 + + + + + + + + + + + + + 垂直居中 + + + + + 单元格 + + 描述信息 + + + + 内容 + + + + + +
+`; diff --git a/packages/cell/test/demo.spec.ts b/packages/cell/test/demo.spec.ts new file mode 100644 index 00000000..4c3798cb --- /dev/null +++ b/packages/cell/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(); +});