From bd9ce42f8d24260f8aeba0b2311767d4c19a4908 Mon Sep 17 00:00:00 2001 From: nemo-shen Date: Mon, 6 Dec 2021 23:57:19 +0800 Subject: [PATCH] test(Panel): add demo test --- example/app.json | 1 + example/pages/panel/index.wxml | 16 +- packages/panel/demo/index.json | 8 + .../panel/demo/index.less | 0 packages/panel/demo/index.ts | 5 + packages/panel/demo/index.wxml | 15 ++ .../test/__snapshots__/demo.spec.ts.snap | 198 ++++++++++++++++++ packages/panel/test/demo.spec.ts | 11 + 8 files changed, 239 insertions(+), 15 deletions(-) create mode 100644 packages/panel/demo/index.json rename example/pages/panel/index.wxss => packages/panel/demo/index.less (100%) create mode 100644 packages/panel/demo/index.ts create mode 100644 packages/panel/demo/index.wxml create mode 100644 packages/panel/test/__snapshots__/demo.spec.ts.snap create mode 100644 packages/panel/test/demo.spec.ts diff --git a/example/app.json b/example/app.json index e0e49d53..c12edc94 100644 --- a/example/app.json +++ b/example/app.json @@ -101,6 +101,7 @@ "van-notice-bar": "./dist/notice-bar/index", "van-notify": "./dist/notify/index", "van-panel": "./dist/panel/index", + "van-panel-demo": "./dist/panel/demo/index", "van-popup": "./dist/popup/index", "van-progress": "./dist/progress/index", "van-radio": "./dist/radio/index", diff --git a/example/pages/panel/index.wxml b/example/pages/panel/index.wxml index 3d9961fe..2e681cf0 100644 --- a/example/pages/panel/index.wxml +++ b/example/pages/panel/index.wxml @@ -1,15 +1 @@ - - - 内容 - - - - - - 内容 - - 按钮 - 按钮 - - - + diff --git a/packages/panel/demo/index.json b/packages/panel/demo/index.json new file mode 100644 index 00000000..3cbf5749 --- /dev/null +++ b/packages/panel/demo/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "van-panel": "../../panel/index", + "van-button": "../../button/index", + "demo-block": "../../../example/components/demo-block/index" + } +} diff --git a/example/pages/panel/index.wxss b/packages/panel/demo/index.less similarity index 100% rename from example/pages/panel/index.wxss rename to packages/panel/demo/index.less diff --git a/packages/panel/demo/index.ts b/packages/panel/demo/index.ts new file mode 100644 index 00000000..a32755a5 --- /dev/null +++ b/packages/panel/demo/index.ts @@ -0,0 +1,5 @@ +import { VantComponent } from '../../common/component'; + +VantComponent({ + data: {}, +}); diff --git a/packages/panel/demo/index.wxml b/packages/panel/demo/index.wxml new file mode 100644 index 00000000..3d9961fe --- /dev/null +++ b/packages/panel/demo/index.wxml @@ -0,0 +1,15 @@ + + + 内容 + + + + + + 内容 + + 按钮 + 按钮 + + + diff --git a/packages/panel/test/__snapshots__/demo.spec.ts.snap b/packages/panel/test/__snapshots__/demo.spec.ts.snap new file mode 100644 index 00000000..d799c3ac --- /dev/null +++ b/packages/panel/test/__snapshots__/demo.spec.ts.snap @@ -0,0 +1,198 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render demo and match snapshot 1`] = ` +
+ + + + 基础用法 + + + + + + + 标题 + + 描述信息 + + + + 状态 + + + + + + 内容 + + + + + + + + + + + 高级用法 + + + + + + + 标题 + + 描述信息 + + + + 状态 + + + + + + 内容 + + + + + + + + 按钮 + + + + + + + 按钮 + + + + + + + + + +
+`; diff --git a/packages/panel/test/demo.spec.ts b/packages/panel/test/demo.spec.ts new file mode 100644 index 00000000..4c3798cb --- /dev/null +++ b/packages/panel/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(); +});