Skip to content

Commit 8262b9f

Browse files
jonathanglasmeyerKent C. Dodds
authored andcommitted
test: improve testing utils (#96)
* test: improve testing utils * test: remove comments
1 parent d16c417 commit 8262b9f

File tree

14 files changed

+28
-260
lines changed

14 files changed

+28
-260
lines changed

src/properties/context/index.test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@ import schema from './index'
22
import { allValid, allInvalid } from '../../../test/utils'
33

44
const validModuleConfigs = [
5-
// #0
65
{ input: 'exists' }, // Absolute
76
]
87

98
const invalidModuleConfigs = [
10-
// #0
11-
// Relative
12-
{ input: './entry.js', error: { type: 'path.absolute' } },
13-
14-
// #1
9+
{ input: './entry.js', error: { type: 'path.absolute' } }, // Relative
1510
{ input: 1, error: { message: '"value" must be a string' } },
1611
]
1712

src/properties/devServer/index.test.js

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,94 +3,50 @@ import { allValid, allInvalid } from '../../../test/utils'
33
import { urlPart } from '../../types'
44

55
const validModuleConfigs = [
6-
// #0
76
{ input: { lazy: true } },
8-
// #1
97
{ input: { inline: true } },
10-
// #2
118
{ input: { stdin: true } },
12-
// #2
139
{ input: { open: true } },
14-
// #4
1510
{ input: { info: true } },
16-
// #5
1711
{ input: { quiet: true } },
18-
// #6
1912
{ input: { https: true } },
20-
// #7
2113
{ input: { key: '/path/to/key' } },
22-
// #8
2314
{ input: { cert: 'path/to/cert' } },
24-
// #9
2515
{ input: { cacert: 'path/to/cacert' } },
26-
// #10
2716
{ input: { contentBase: '/content/base' } },
28-
// #11
2917
{ input: { contentBase: { target: '/content/base/' } } },
30-
// #12
3118
{ input: { contentBase: ['/content/base/'] } },
32-
// #13
3319
{ input: { historyApiFallback: true } },
34-
// #14
3520
{ input: { historyApiFallback: { index: '/foo-app/' } } },
36-
// #15
3721
{ input: { compress: true } },
38-
// #16
3922
{ input: { port: 3000 } },
40-
// #17
4123
{ input: { public: 'localhost' } },
42-
// #18
4324
{ input: { host: '0.0.0.0' } },
44-
// #19
4525
{ input: { publicPath: '/public/path/' } },
46-
// #20
4726
{ input: { publicPath: 'public/path/' } },
48-
// #21
4927
{ input: { outputPath: '/' } },
50-
// #22
5128
{ input: { filename: 'bundle.js' } },
52-
// #23
5329
{ input: { watchOptions: {} } },
54-
// #24
5530
{ input: { hot: true } },
56-
// #25
5731
{ input: { stats: {} } },
58-
// #26
5932
{ input: { stats: 'none' } },
60-
// #27
6133
{ input: { stats: 'errors-only' } },
62-
// #28
6334
{ input: { stats: 'minimal' } },
64-
// #29
6535
{ input: { stats: 'normal' } },
66-
// #30
6736
{ input: { stats: 'verbose' } },
68-
// #31
6937
{ input: { noInfo: true } },
70-
// #32
7138
{ input: { proxy: {} } },
72-
// #33
73-
{ input: { proxy: 'http://proxy.url/' } },
74-
// #34
7539
{ input: { proxy: [] } },
76-
// #35
7740
{ input: { staticOptions: {} } },
78-
// #36
7941
{ input: { headers: {} } },
8042
]
8143

8244
const invalidModuleConfigs = [
83-
// #0
8445
{ input: { publicPath: 'public/path' }, error: { message: `"publicPath" ${urlPart.message}` } },
85-
// #1
8646
{ input: { outputPath: './output/path' }, error: { message: `"outputPath" ${urlPart.message}` } },
87-
// #2
8847
{ input: { watchOptions: true } },
89-
// #3
9048
{ input: { stats: true } },
91-
// #4
9249
{ input: { stats: 'foobar' } },
93-
// #5
9450
{ input: { proxy: true } },
9551
]
9652

src/properties/devtool/index.test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,19 @@ import schema from './index'
22
import { allValid, allInvalid } from '../../../test/utils'
33

44
const validModuleConfigs = [
5-
// #0
65
{ input: 'eval' },
7-
// #1
86
{ input: '#@eval' },
9-
// #2
107
{ input: '#cheap-module-eval-source-map' },
11-
// #3
128
{ input: 'hidden-source-map' },
13-
// #4
149
{ input: 'inline-source-map' },
15-
// #5
1610
{ input: 'eval-source-map' },
17-
// #6
1811
{ input: 'cheap-source-map' },
1912
]
2013

2114
const invalidModuleConfigs = [
22-
// #0
2315
{ input: 'foo', error: { } },
24-
// #1
2516
{ input: 'eval-source-map-foo', error: { } },
26-
// #2
2717
{ input: 'foo-cheap-source-map', error: { } },
28-
// #3
2918
{ input: '#@eval-foo', error: { } },
3019
]
3120

src/properties/entry/index.test.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,15 @@ import schema from './index'
22
import { allValid, allInvalid } from '../../../test/utils'
33

44
const validModuleConfigs = [
5-
// #0
65
{ input: './entry.js' },
7-
8-
// #1
96
{ input: ['./entry.js'] },
10-
11-
// #2
127
{ input: { foo: './entry.js', bar: ['./bar.js'] } },
138
]
149

1510
const invalidModuleConfigs = [
16-
// #0
1711
{ input: 1, error: { message: '"value" must be a string' } },
18-
19-
// #1
2012
{ input: [1], error: { message: '"0" must be a string' } },
21-
22-
// #2
2313
{ input: [1, 'foo'], error: { message: '"0" must be a string' } },
24-
25-
// #3
2614
{ input: { foo: 1, bar: ['./bar.js'] }, error: { message: '"value" must be a string' } },
2715
]
2816

src/properties/externals/index.test.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,17 @@ import schema, { EXTERNALS_MESSAGE } from './index'
22
import { allValid, allInvalid } from '../../../test/utils'
33

44
const validModuleConfigs = [
5-
// #0
65
{ input: 'dependency' },
7-
8-
// #1
96
{ input: ['dependency'] },
10-
11-
// #2 ( from https://webpack.github.io/docs/configuration.html#externals )
127
{
8+
// from https://webpack.github.io/docs/configuration.html#externals )
139
input: {
1410
a: false,
1511
b: true,
1612
'./c': 'c',
1713
'./d': 'var d',
1814
},
1915
},
20-
21-
// #3 ( from real life )
2216
{
2317
input: [
2418
{
@@ -32,16 +26,11 @@ const validModuleConfigs = [
3226
},
3327
],
3428
},
35-
36-
// #4
3729
{ input: /dependency/ },
38-
39-
// #5
4030
{ input: (a, b, c) => { } }, // eslint-disable-line
4131
]
4232

4333
const invalidModuleConfigs = [
44-
// #0
4534
{
4635
input: {
4736
a: ['foo'],
@@ -51,8 +40,6 @@ const invalidModuleConfigs = [
5140
},
5241
error: { message: `"value" ${EXTERNALS_MESSAGE}` },
5342
},
54-
55-
// #1
5643
{
5744
input: [{
5845
a: ['foo'],
@@ -62,16 +49,12 @@ const invalidModuleConfigs = [
6249
}],
6350
error: { message: `"value" ${EXTERNALS_MESSAGE}` },
6451
},
65-
66-
// #2
6752
{
6853
input: 1,
6954
error: { message: `"value" ${EXTERNALS_MESSAGE}` },
7055
},
71-
72-
// #3
73-
// Only 3-arity allowed
7456
{
57+
// Only 3-arity allowed
7558
input: (a, b, c, d) => { }, // eslint-disable-line
7659
error: { message: `"value" ${EXTERNALS_MESSAGE}` },
7760
},

src/properties/module/index.test.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,34 @@ import moduleSchema, { CONDITION_MESSAGE, LOADERS_QUERY_MESSAGE } from './index'
22
import { allValid, allInvalid } from '../../../test/utils'
33

44
const validModuleConfigs = [
5-
// #0
65
{
76
input: {
87
loaders: [
98
{ test: 'foo', include: /src/, loader: 'babel' },
109
],
1110
},
1211
},
13-
// #1
1412
{
1513
input: {
1614
loaders: [
1715
{ test: /\.less$/, loader: 'style-loader!css-loader!autoprefixer-loader!less-loader' },
1816
],
1917
},
2018
},
21-
// #2
2219
{
2320
input: {
2421
loaders: [
2522
{ test: /\.(?:eot|ttf|woff2?)$/, loaders: ['file-loader'] },
2623
],
2724
},
2825
},
29-
// #3
3026
{
3127
input: {
3228
loaders: [
3329
{ test: (absPath) => absPath && true, loaders: ['file-loader'] },
3430
],
3531
},
3632
},
37-
// #4
3833
{
3934
input: {
4035
loaders: [
@@ -45,7 +40,6 @@ const validModuleConfigs = [
4540
]
4641

4742
const invalidModuleConfigs = [
48-
// #0
4943
{
5044
input: {
5145
loaders: [
@@ -54,7 +48,6 @@ const invalidModuleConfigs = [
5448
},
5549
error: { message: '"test" is required' },
5650
},
57-
// #1
5851
{
5952
input: {
6053
loaders: [
@@ -63,7 +56,6 @@ const invalidModuleConfigs = [
6356
},
6457
error: { message: `"include" ${CONDITION_MESSAGE}` },
6558
},
66-
// #2
6759
{
6860
input: {
6961
loaders: [
@@ -72,7 +64,6 @@ const invalidModuleConfigs = [
7264
},
7365
error: { message: '"loaders" must be an array' },
7466
},
75-
// #3
7667
{
7768
input: {
7869
loaders: [
@@ -81,44 +72,38 @@ const invalidModuleConfigs = [
8172
},
8273
error: { message: '"0" must be a string', path: 'loaders.0.loaders.0' },
8374
},
84-
// #4
8575
{
8676
input: {
8777
loaders: [{ test: /\.(?:eot|ttf|woff2?)$/, loader: ['file-loader'] }],
8878
},
8979
error: { message: '"loader" must be a string' },
9080
},
91-
// #5
9281
{
9382
input: {
9483
loaders: [{ test: /\.(?:eot|ttf|woff2?)$/, loaders: ['file-loader'], loader: 'style' }],
9584
},
9685
error: { message: '"value" contains a conflict between exclusive peers [loaders, loader]' },
9786
},
98-
// #6
9987
{
10088
input: {
10189
loaders: [{ test: (foo, bar) => `${foo}-${bar}`, loaders: ['file-loader'] }],
10290
},
10391
// Only 1-arity functions are allowed
10492
error: { message: `"test" ${CONDITION_MESSAGE}` },
10593
},
106-
// #7
10794
{
10895
input: {
10996
loaders: [{ query: { foo: 'bar' }, loaders: ['file-loader'], test: /foo/ }],
11097
},
11198
// query can only be supplied when `loader` property is supplied
11299
error: { message: `"value" ${LOADERS_QUERY_MESSAGE}` },
113100
},
114-
// #8
115101
{
116102
input: {
117103
loaders: [{ test: /foo/ }],
118104
},
119105
error: { message: '"value" must contain at least one of [loaders, loader]' },
120106
},
121-
// #9
122107
{
123108
input: {
124109
loaders: [{ test: /foo/, loader: 'foo', query: 'query' }],

src/properties/node/index.test.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,16 @@ import schema from './index'
22
import { allValid, allInvalid } from '../../../test/utils'
33

44
const validModuleConfigs = [
5-
// #0
65
{ input: { console: true } },
7-
8-
// #1
96
{ input: { global: true } },
10-
11-
// #2
127
{ input: { Buffer: true } },
13-
14-
// #3
158
{ input: { process: 'mock' } },
16-
17-
// #4
189
{ input: { __filename: true } },
19-
20-
// #5
2110
{ input: { __dirname: false } },
22-
23-
// #6
2411
{ input: { foo: 'mock' } },
2512
]
2613

2714
const invalidModuleConfigs = [
28-
// #0
29-
// { input: { foo: 'mocka' }, error: { } },
30-
31-
// #0
3215
{ input: [1], error: { } },
3316
]
3417

0 commit comments

Comments
 (0)