Skip to content

Commit 78e4c7c

Browse files
committed
test: improve unit testing
1 parent eaabb87 commit 78e4c7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2320
-1573
lines changed

jest.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
bail: 1,
3+
verbose: true,
4+
testEnvironment: 'jsdom',
5+
testURL: 'https://jest.test',
6+
moduleFileExtensions: ['js', 'ts'],
7+
testMatch: ['<rootDir>/src/**/__test__/**/*.test.{js,ts}'],
8+
collectCoverageFrom: [
9+
'<rootDir>/src/**/*.{js,ts}',
10+
'!<rootDir>/src/weui-wxss/**',
11+
'!**/__test__/**'
12+
],
13+
snapshotSerializers: ['miniprogram-simulate/jest-snapshot-plugin']
14+
}

package-lock.json

+1,693-1,142
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"clean-dev": "gulp clean --develop",
1515
"clean": "gulp clean",
1616
"lint": "eslint \"src/**/*.js\"",
17-
"lint-tools": "eslint \"tools/**/*.js\" --rule \"import/no-extraneous-dependencies: false\""
17+
"lint-tools": "eslint \"tools/**/*.js\" --rule \"import/no-extraneous-dependencies: false\"",
18+
"test": "jest"
1819
},
1920
"miniprogram": "miniprogram_dist",
2021
"repository": {
@@ -31,6 +32,7 @@
3132
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
3233
"@babel/preset-env": "^7.8.7",
3334
"@babel/preset-typescript": "^7.8.3",
35+
"@types/jest": "^25.2.2",
3436
"@typescript-eslint/eslint-plugin": "^2.23.0",
3537
"@typescript-eslint/parser": "^2.23.0",
3638
"autoprefixer": "^6.5.1",
@@ -53,9 +55,10 @@
5355
"gulp-less": "^4.0.1",
5456
"gulp-rename": "^1.4.0",
5557
"gulp-sourcemaps": "^2.6.5",
56-
"jest": "^25.1.0",
58+
"jest": "^25.5.4",
59+
"jsdom": "^16.2.2",
5760
"miniprogram-api-typings": "^2.6.5",
58-
"miniprogram-simulate": "^1.1.5",
61+
"miniprogram-simulate": "^1.2.2",
5962
"prettier": "2.0.1",
6063
"through2": "^2.0.3",
6164
"ts-loader": "^5.3.3",

src/@types/component.d.ts

-168
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`actionsheet basic actionsheet 1`] = `
4+
<mp-actionsheet
5+
class="comp"
6+
bind:actiontap="actiontap"
7+
bind:close="close"
8+
>
9+
<wx-view
10+
class="weui-mask customer-mask-class"
11+
bind:tap="closeActionSheet"
12+
/>
13+
<wx-view
14+
class="weui-actionsheet weui-actionsheet_toggle "
15+
>
16+
<wx-view
17+
class="weui-actionsheet__title"
18+
>
19+
<wx-view
20+
class="weui-actionsheet__title-text"
21+
>
22+
actionsheet title
23+
</wx-view>
24+
</wx-view>
25+
<wx-view
26+
class="weui-actionsheet__menu"
27+
>
28+
<wx-view
29+
class="weui-actionsheet__cell "
30+
data-groupindex="{{0}}"
31+
data-index="{{0}}"
32+
data-value="{{1}}"
33+
bind:tap="buttonTap"
34+
>
35+
36+
item 1
37+
38+
</wx-view>
39+
<wx-view
40+
class="weui-actionsheet__cell "
41+
data-groupindex="{{0}}"
42+
data-index="{{1}}"
43+
data-value="{{2}}"
44+
bind:tap="buttonTap"
45+
>
46+
47+
item 2
48+
49+
</wx-view>
50+
<wx-view
51+
class="weui-actionsheet__cell weui-actionsheet__cell_warn"
52+
data-groupindex="{{0}}"
53+
data-index="{{2}}"
54+
data-value="{{3}}"
55+
bind:tap="buttonTap"
56+
>
57+
58+
item 3
59+
60+
</wx-view>
61+
</wx-view>
62+
<wx-view
63+
class="weui-actionsheet__action"
64+
>
65+
<wx-view
66+
class="weui-actionsheet__cell"
67+
data-type="close"
68+
id="iosActionsheetCancel"
69+
bind:tap="closeActionSheet"
70+
>
71+
actionsheet cancel text
72+
</wx-view>
73+
</wx-view>
74+
</wx-view>
75+
</mp-actionsheet>
76+
`;
77+
78+
exports[`actionsheet no cancel 1`] = `
79+
<mp-actionsheet
80+
class="comp"
81+
bind:actiontap="actiontap"
82+
bind:close="close"
83+
>
84+
<wx-view
85+
class="weui-mask customer-mask-class"
86+
bind:tap="closeActionSheet"
87+
/>
88+
<wx-view
89+
class="weui-actionsheet weui-actionsheet_toggle "
90+
>
91+
<wx-view
92+
class="weui-actionsheet__title"
93+
>
94+
<wx-view
95+
class="weui-actionsheet__title-text"
96+
>
97+
actionsheet title
98+
</wx-view>
99+
</wx-view>
100+
<wx-view
101+
class="weui-actionsheet__action"
102+
>
103+
<wx-view
104+
class="weui-actionsheet__cell "
105+
data-groupindex="{{0}}"
106+
data-index="{{0}}"
107+
data-value="{{1}}"
108+
bind:tap="buttonTap"
109+
>
110+
111+
item 1
112+
113+
</wx-view>
114+
<wx-view
115+
class="weui-actionsheet__cell "
116+
data-groupindex="{{0}}"
117+
data-index="{{1}}"
118+
data-value="{{2}}"
119+
bind:tap="buttonTap"
120+
>
121+
122+
item 2
123+
124+
</wx-view>
125+
<wx-view
126+
class="weui-actionsheet__cell weui-actionsheet__cell_warn"
127+
data-groupindex="{{0}}"
128+
data-index="{{2}}"
129+
data-value="{{3}}"
130+
bind:tap="buttonTap"
131+
>
132+
133+
item 3
134+
135+
</wx-view>
136+
</wx-view>
137+
</wx-view>
138+
</mp-actionsheet>
139+
`;

0 commit comments

Comments
 (0)