diff --git a/example/app.json b/example/app.json
index 80560d1b..fbfda951 100644
--- a/example/app.json
+++ b/example/app.json
@@ -100,6 +100,7 @@
"van-nav-bar": "./dist/nav-bar/index",
"van-notice-bar": "./dist/notice-bar/index",
"van-notify": "./dist/notify/index",
+ "van-notify-demo": "./dist/notify/demo/index",
"van-panel": "./dist/panel/index",
"van-panel-demo": "./dist/panel/demo/index",
"van-popup": "./dist/popup/index",
diff --git a/example/pages/notify/index.js b/example/pages/notify/index.js
index ff74b16f..cc11dfda 100644
--- a/example/pages/notify/index.js
+++ b/example/pages/notify/index.js
@@ -1,40 +1,3 @@
import Page from '../../common/page';
-import Notify from '../../dist/notify/notify';
-Page({
- showNotify() {
- Notify('通知内容');
- },
-
- showCustomColor() {
- Notify({
- message: '自定义颜色',
- color: '#ad0000',
- background: '#ffe1e1'
- });
-
- Notify.clear();
- },
-
- showCustomDuration() {
- Notify({
- duration: 1000,
- message: '自定义时长'
- });
- },
-
- showNotifyByType(event) {
- const { type } = event.currentTarget.dataset;
- Notify({
- type,
- message: '通知内容'
- });
- },
-
- showSafe() {
- Notify({
- message: '通知内容',
- safeAreaInsetTop: true
- });
- }
-});
+Page();
diff --git a/example/pages/notify/index.wxml b/example/pages/notify/index.wxml
index c6a7cc33..29eac634 100644
--- a/example/pages/notify/index.wxml
+++ b/example/pages/notify/index.wxml
@@ -1,25 +1 @@
-
- 基础用法
-
-
-
-
- 主要通知
- 成功通知
-
-
- 危险通知
- 警告通知
-
-
-
-
- 自定义颜色
- 自定义时长
-
-
-
- 插入状态栏高度
-
-
-
+
diff --git a/example/pages/notify/index.wxss b/example/pages/notify/index.wxss
deleted file mode 100644
index 4810b9e0..00000000
--- a/example/pages/notify/index.wxss
+++ /dev/null
@@ -1 +0,0 @@
-/* pages/notify/index.wxss */
\ No newline at end of file
diff --git a/packages/notify/demo/index.json b/packages/notify/demo/index.json
new file mode 100644
index 00000000..5ff69869
--- /dev/null
+++ b/packages/notify/demo/index.json
@@ -0,0 +1,8 @@
+{
+ "component": true,
+ "usingComponents": {
+ "van-button": "../../button/index",
+ "van-notify": "../../notify/index",
+ "demo-block": "../../../example/components/demo-block/index"
+ }
+}
diff --git a/packages/notify/demo/index.ts b/packages/notify/demo/index.ts
new file mode 100644
index 00000000..cb32620a
--- /dev/null
+++ b/packages/notify/demo/index.ts
@@ -0,0 +1,46 @@
+import { VantComponent } from '../../common/component';
+import Notify from '../../notify/notify';
+
+VantComponent({
+ methods: {
+ showNotify() {
+ Notify({ context: this, message: '通知内容' });
+ },
+
+ showCustomColor() {
+ Notify({
+ context: this,
+ message: '自定义颜色',
+ color: '#ad0000',
+ background: '#ffe1e1',
+ });
+
+ Notify.clear();
+ },
+
+ showCustomDuration() {
+ Notify({
+ context: this,
+ duration: 1000,
+ message: '自定义时长',
+ });
+ },
+
+ showNotifyByType(event) {
+ const { type } = event.currentTarget.dataset;
+ Notify({
+ type,
+ context: this,
+ message: '通知内容',
+ });
+ },
+
+ showSafe() {
+ Notify({
+ context: this,
+ message: '通知内容',
+ safeAreaInsetTop: true,
+ });
+ },
+ },
+});
diff --git a/packages/notify/demo/index.wxml b/packages/notify/demo/index.wxml
new file mode 100644
index 00000000..c6a7cc33
--- /dev/null
+++ b/packages/notify/demo/index.wxml
@@ -0,0 +1,25 @@
+
+ 基础用法
+
+
+
+
+ 主要通知
+ 成功通知
+
+
+ 危险通知
+ 警告通知
+
+
+
+
+ 自定义颜色
+ 自定义时长
+
+
+
+ 插入状态栏高度
+
+
+
diff --git a/packages/notify/test/__snapshots__/demo.spec.ts.snap b/packages/notify/test/__snapshots__/demo.spec.ts.snap
new file mode 100644
index 00000000..bf440fa7
--- /dev/null
+++ b/packages/notify/test/__snapshots__/demo.spec.ts.snap
@@ -0,0 +1,354 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render demo and match snapshot 1`] = `
+
+
+
+
+ 基础用法
+
+
+
+
+ 基础用法
+
+
+
+
+
+
+
+
+ 通知类型
+
+
+
+
+
+ 主要通知
+
+
+
+
+
+
+ 成功通知
+
+
+
+
+
+
+
+
+ 危险通知
+
+
+
+
+
+
+ 警告通知
+
+
+
+
+
+
+
+
+
+ 自定义通知
+
+
+
+
+ 自定义颜色
+
+
+
+
+
+
+ 自定义时长
+
+
+
+
+
+
+
+
+ 插入状态栏高度
+
+
+
+
+ 插入状态栏高度
+
+
+
+
+
+
+
+
+
+`;
diff --git a/packages/notify/test/demo.spec.ts b/packages/notify/test/demo.spec.ts
new file mode 100644
index 00000000..4c3798cb
--- /dev/null
+++ b/packages/notify/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();
+});