diff --git a/example/app.json b/example/app.json index 53fe3770..b254713b 100644 --- a/example/app.json +++ b/example/app.json @@ -95,6 +95,7 @@ "van-image": "./dist/image/index", "van-image-demo": "./dist/image/demo/index", "van-loading": "./dist/loading/index", + "van-loading-demo": "./dist/loading/demo/index", "van-nav-bar": "./dist/nav-bar/index", "van-notice-bar": "./dist/notice-bar/index", "van-notify": "./dist/notify/index", diff --git a/example/pages/loading/index.wxml b/example/pages/loading/index.wxml index 0df0d077..7f313b0e 100644 --- a/example/pages/loading/index.wxml +++ b/example/pages/loading/index.wxml @@ -1,17 +1 @@ - - - - - - - - - - - - 加载中... - - - - 加载中... - + diff --git a/packages/loading/demo/index.json b/packages/loading/demo/index.json new file mode 100644 index 00000000..90ce2efb --- /dev/null +++ b/packages/loading/demo/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-loading": "../../loading/index", + "demo-block": "../../../example/components/demo-block/index" + } +} diff --git a/example/pages/loading/index.wxss b/packages/loading/demo/index.less similarity index 100% rename from example/pages/loading/index.wxss rename to packages/loading/demo/index.less diff --git a/packages/loading/demo/index.ts b/packages/loading/demo/index.ts new file mode 100644 index 00000000..a32755a5 --- /dev/null +++ b/packages/loading/demo/index.ts @@ -0,0 +1,5 @@ +import { VantComponent } from '../../common/component'; + +VantComponent({ + data: {}, +}); diff --git a/packages/loading/demo/index.wxml b/packages/loading/demo/index.wxml new file mode 100644 index 00000000..0df0d077 --- /dev/null +++ b/packages/loading/demo/index.wxml @@ -0,0 +1,17 @@ + + + + + + + + + + + + 加载中... + + + + 加载中... + diff --git a/packages/loading/test/__snapshots__/demo.spec.ts.snap b/packages/loading/test/__snapshots__/demo.spec.ts.snap new file mode 100644 index 00000000..a8d8fee8 --- /dev/null +++ b/packages/loading/test/__snapshots__/demo.spec.ts.snap @@ -0,0 +1,224 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render demo and match snapshot 1`] = ` +
+ + + + 加载类型 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 自定义颜色 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 加载文案 + + + + + + 加载中... + + + + + + + + + 垂直排列 + + + + + + 加载中... + + + + + +
+`; diff --git a/packages/loading/test/demo.spec.ts b/packages/loading/test/demo.spec.ts new file mode 100644 index 00000000..4c3798cb --- /dev/null +++ b/packages/loading/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(); +});