forked from lspriv/wx-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
37 lines (31 loc) · 1.08 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* @Description: test
* @Author: lspriv
* @LastEditTime: 2023-12-26 17:28:24
*/
const path = require('path');
const simulate = require('miniprogram-simulate');
const predef = require('./predefine');
const originalComponent = global.Component;
global.Component = options => {
options.methods = {
...options.methods,
applyAnimatedStyle: predef.applyAnimatedStyle,
clearAnimatedStyle: predef.clearAnimatedStyle
};
originalComponent(options);
};
test('component', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
var wx = predef;
// 加载自定义组件,返回组件 id
const id = simulate.load(path.resolve(__dirname, '../dev/components/wx-calendar/index'));
// 使用 id 渲染自定义组件,返回组件封装实例
const component = simulate.render(id);
// 创建容器节点
const parent = document.createElement('parent-wrapper');
// 将组件插入到容器节点中,会触发 attached 生命周期
component.attach(parent);
// 将组件从容器节点中移除,会触发 detached 生命周期
component.detach();
});