diff --git a/example/app.json b/example/app.json index 36d66afa..3050378a 100644 --- a/example/app.json +++ b/example/app.json @@ -85,6 +85,7 @@ "van-divider": "./dist/divider/index", "van-divider-demo": "./dist/divider/demo/index", "van-empty": "./dist/empty/index", + "van-empty-demo": "./dist/empty/demo/index", "van-field": "./dist/field/index", "van-goods-action": "./dist/goods-action/index", "van-goods-action-icon": "./dist/goods-action-icon/index", diff --git a/example/pages/empty/index.js b/example/pages/empty/index.js index d0a25c57..cc11dfda 100644 --- a/example/pages/empty/index.js +++ b/example/pages/empty/index.js @@ -1,13 +1,3 @@ import Page from '../../common/page'; -Page({ - data: { - activeTab: 0, - }, - - onChange(event) { - this.setData({ - activeTab: event.detail.name, - }); - }, -}); +Page(); diff --git a/example/pages/empty/index.wxml b/example/pages/empty/index.wxml index a661b534..29f239b9 100644 --- a/example/pages/empty/index.wxml +++ b/example/pages/empty/index.wxml @@ -1,36 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - 按钮 - - - \ No newline at end of file + diff --git a/packages/empty/demo/index.json b/packages/empty/demo/index.json new file mode 100644 index 00000000..5fd7af0b --- /dev/null +++ b/packages/empty/demo/index.json @@ -0,0 +1,10 @@ +{ + "component": true, + "usingComponents": { + "van-tab": "../../tab/index", + "van-tabs": "../../tabs/index", + "van-empty": "../../empty/index", + "van-button": "../../button/index", + "demo-block": "../../../example/components/demo-block/index" + } +} diff --git a/example/pages/empty/index.wxss b/packages/empty/demo/index.less similarity index 98% rename from example/pages/empty/index.wxss rename to packages/empty/demo/index.less index da81592c..bffacf30 100644 --- a/example/pages/empty/index.wxss +++ b/packages/empty/demo/index.less @@ -1,4 +1,3 @@ - .custom-image .van-empty__image { width: 90px; height: 90px; @@ -7,4 +6,4 @@ .bottom-button { width: 160px; height: 40px; -} \ No newline at end of file +} diff --git a/packages/empty/demo/index.ts b/packages/empty/demo/index.ts new file mode 100644 index 00000000..b5c6e28d --- /dev/null +++ b/packages/empty/demo/index.ts @@ -0,0 +1,15 @@ +import { VantComponent } from '../../common/component'; + +VantComponent({ + data: { + activeTab: 0, + }, + + methods: { + onChange(event) { + this.setData({ + activeTab: event.detail.name, + }); + }, + }, +}); diff --git a/packages/empty/demo/index.wxml b/packages/empty/demo/index.wxml new file mode 100644 index 00000000..e121fc5c --- /dev/null +++ b/packages/empty/demo/index.wxml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + 按钮 + + + diff --git a/packages/empty/index.wxs b/packages/empty/index.wxs index 9696dd47..cf92ece3 100644 --- a/packages/empty/index.wxs +++ b/packages/empty/index.wxs @@ -12,3 +12,4 @@ function imageUrl(image) { module.exports = { imageUrl: imageUrl, }; + diff --git a/packages/empty/test/__snapshots__/demo.spec.ts.snap b/packages/empty/test/__snapshots__/demo.spec.ts.snap new file mode 100644 index 00000000..cefd8f5e --- /dev/null +++ b/packages/empty/test/__snapshots__/demo.spec.ts.snap @@ -0,0 +1,330 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render demo and match snapshot 1`] = ` +
+ + + + 基础用法 + + + + + + + + + + + 描述文字 + + + + + + + + + + + 图片类型 + + + + + + + + + + + + + + 通用错误 + + + + + + + 网络错误 + + + + + + + 搜索提示 + + + + + + + + + + + + + + + + + + + + + + + 描述文字 + + + + + + + + + + + + + + + + + + + + + 自定义图片 + + + + + + + + + + + 描述文字 + + + + + + + + + + + 底部内容 + + + + + + + + + + + 描述文字 + + + + + + + + 按钮 + + + + + + + + + +
+`; diff --git a/packages/empty/test/demo.spec.ts b/packages/empty/test/demo.spec.ts new file mode 100644 index 00000000..4c3798cb --- /dev/null +++ b/packages/empty/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(); +});