Skip to content

Commit 4fe5cc3

Browse files
committed
adjust test cases for changed debug and error messages
1 parent 4dac73a commit 4fe5cc3

12 files changed

+71
-29
lines changed

test/cases/absolute-asset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const {
1919

2020
const assertDebugMessages = assertStdout('debug')(1)`
2121
^resolve-url-loader:[^:]+:[ ]+${process.cwd()}.*${join('images', 'img.jpg')}
22-
[ ]+-empty-
22+
[ ]+-empty- --> ./images/img.jpg
2323
[ ]+FOUND$
2424
`;
2525

test/cases/adjacent-asset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const {
2020

2121
const assertDebugMessages = assertStdout('debug')(1)`
2222
^resolve-url-loader:[^:]+:[ ]*${'../../../packageB/images/img.jpg'}
23-
[ ]+${'./src/feature'}
23+
[ ]+${'./src/feature'} --> ${'../packageB/images/img.jpg'}
2424
[ ]+FOUND$
2525
`;
2626

test/cases/common/test/invalid.js

+32-6
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,58 @@ exports.testFail = (...rest) =>
7171
)
7272
);
7373

74-
exports.testNonFunctionJoin = (...rest) =>
74+
exports.testNonFunctionJoin1 = (...rest) =>
7575
test(
76-
'join=!function',
76+
'join1=!function',
7777
layer()(
7878
env({
7979
LOADER_JOIN: 'return 1;',
80-
OUTPUT: 'non-function-join'
80+
OUTPUT: 'non-function-join1'
8181
}),
8282
...rest,
8383
test('validate', assertStderr('options.join')(1)`join: 1`)
8484
)
8585
);
8686

87-
exports.testWrongArityJoin = (...rest) =>
87+
exports.testWrongArityJoin1 = (...rest) =>
8888
test(
89-
'join=!arity1',
89+
'join1=!arity2',
90+
layer()(
91+
env({
92+
LOADER_JOIN: 'return (a) => (b) => undefined;',
93+
OUTPUT: 'wrong-arity-join1'
94+
}),
95+
...rest,
96+
test('validate', assertStderr('options.join')(1)`join: \(a\) => \(b\) => undefined`)
97+
)
98+
);
99+
100+
exports.testNonFunctionJoin2 = (...rest) =>
101+
test(
102+
'join2=!function',
90103
layer()(
91104
env({
92105
LOADER_JOIN: 'return (a, b) => undefined;',
93-
OUTPUT: 'wrong-arity-join'
106+
OUTPUT: 'non-function-join2'
94107
}),
95108
...rest,
96109
test('validate', assertStderr('options.join')(1)`join: \(a, b\) => undefined`)
97110
)
98111
);
99112

113+
exports.testWrongArityJoin2 = (...rest) =>
114+
test(
115+
'join2=!arity',
116+
layer()(
117+
env({
118+
LOADER_JOIN: 'return (a, b) => (c, d) => undefined;',
119+
OUTPUT: 'wrong-arity-join2'
120+
}),
121+
...rest,
122+
test('validate', assertStderr('options.join')(1)`join: \(a, b\) => \(c, d\) => undefined`)
123+
)
124+
);
125+
100126
exports.testNonStringRoot = (...rest) =>
101127
test(
102128
'root=!string',

test/cases/declaration-mixin.postcss.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ const {
2020

2121
const assertIncludeMessages = assertStdout('debug')(1)`
2222
^resolve-url-loader:[^:]+:[ ]*${'img.jpg'}
23-
[ ]+${'./src/feature'}
24-
[ ]+${'./src'}
23+
[ ]+${'./src/feature'} --> ${'./src/feature/img.jpg'}
24+
[ ]+${'./src'} --> ${'./src/img.jpg'}
2525
[ ]+FOUND$
2626
`;
2727

2828
const assertMixinMessages = assertStdout('debug')(1)`
2929
^resolve-url-loader:[^:]+:[ ]*${'img.jpg'}
30-
[ ]+${'./src/feature'}
30+
[ ]+${'./src/feature'} --> ${'./src/feature/img.jpg'}
3131
[ ]+FOUND$
3232
`;
3333

test/cases/declaration-variable.postcss.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ const {
2020

2121
const assertPropertyMessages = assertStdout('debug')(1)`
2222
^resolve-url-loader:[^:]+:[ ]*${'img.jpg'}
23-
[ ]+${'./src/value/substring'}
24-
[ ]+${'./src/value'}
25-
[ ]+${'./src'}
23+
[ ]+${'./src/value/substring'} --> ${'./src/value/substring/img.jpg'}
24+
[ ]+${'./src/value'} --> ${'./src/value/img.jpg'}
25+
[ ]+${'./src'} --> ${'./src/img.jpg'}
2626
[ ]+FOUND$
2727
`;
2828

2929
const assertValueMessages = assertStdout('debug')(1)`
3030
^resolve-url-loader:[^:]+:[ ]*${'img.jpg'}
31-
[ ]+${'./src/value/substring'}
32-
[ ]+${'./src/value'}
31+
[ ]+${'./src/value/substring'} --> ${'./src/value/substring/img.jpg'}
32+
[ ]+${'./src/value'} --> ${'./src/value/img.jpg'}
3333
[ ]+FOUND$
3434
`;
3535

3636
const assertSubstringMessages = assertStdout('debug')(1)`
3737
^resolve-url-loader:[^:]+:[ ]*${'img.jpg'}
38-
[ ]+${'./src/value/substring'}
38+
[ ]+${'./src/value/substring'} --> ${'./src/value/substring/img.jpg'}
3939
[ ]+FOUND$
4040
`;
4141

test/cases/deep-asset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const {
2020

2121
const assertDebugMessages = assertStdout('debug')(1)`
2222
^resolve-url-loader:[^:]+:[ ]*${'images/img.jpg'}
23-
[ ]+${'./src/feature'}
23+
[ ]+${'./src/feature'} --> ${'./src/feature/images/img.jpg'}
2424
[ ]+FOUND$
2525
`;
2626

test/cases/immediate-asset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const {
2020

2121
const assertDebugMessages = assertStdout('debug')(1)`
2222
^resolve-url-loader:[^:]+:[ ]*${'img.jpg'}
23-
[ ]+${'./src/feature'}
23+
[ ]+${'./src/feature'} --> ${'./src/feature/img.jpg'}
2424
[ ]+FOUND$
2525
`;
2626

test/cases/misconfiguration.js

+21-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const {trim} = require('../lib/util');
1010
const {rebaseToCache} = require('../lib/higher-order');
1111
const {
1212
all, testDefault, testSilent, testKeepQuery, testAbsolute, testAttempts, testEngineFailInitialisation,
13-
testEngineFailProcessing, testIncludeRoot, testFail, testNonFunctionJoin, testWrongArityJoin, testNonStringRoot,
14-
testNonExistentRoot
13+
testEngineFailProcessing, testIncludeRoot, testFail, testNonFunctionJoin1, testWrongArityJoin1, testNonFunctionJoin2,
14+
testWrongArityJoin2, testNonStringRoot, testNonExistentRoot
1515
} = require('./common/test');
1616
const {buildDevNormal, buildProdNormal} = require('./common/exec');
1717
const {assertCssContent} = require('../lib/assert');
@@ -246,19 +246,35 @@ module.exports = test(
246246
)
247247
)
248248
),
249-
testNonFunctionJoin(
249+
testNonFunctionJoin1(
250250
all(testDefault, testSilent)(
251251
all(buildDevNormal, buildProdNormal)(
252252
assertWebpackNotOk,
253253
assertMisconfigError('"join" option must be a Function')
254254
)
255255
)
256256
),
257-
testWrongArityJoin(
257+
testWrongArityJoin1(
258258
all(testDefault, testSilent)(
259259
all(buildDevNormal, buildProdNormal)(
260260
assertWebpackNotOk,
261-
assertMisconfigError('"join" Function must take exactly 1 arguments (options hash)')
261+
assertMisconfigError('"join" Function must take exactly 2 arguments (options, loader)')
262+
)
263+
)
264+
),
265+
testNonFunctionJoin2(
266+
all(testDefault, testSilent)(
267+
all(buildDevNormal, buildProdNormal)(
268+
assertWebpackNotOk,
269+
assertMisconfigError('"join" option must itself return a Function when it is called')
270+
)
271+
)
272+
),
273+
testWrongArityJoin2(
274+
all(testDefault, testSilent)(
275+
all(buildDevNormal, buildProdNormal)(
276+
assertWebpackNotOk,
277+
assertMisconfigError('"join" Function must create a function that takes exactly 1 arguments (item)')
262278
)
263279
)
264280
),

test/cases/orphan-carriage-return.postcss.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const {
2020

2121
const assertDebugMessages = assertStdout('debug')(1)`
2222
^resolve-url-loader:[^:]+:[ ]*${'img.jpg'}
23-
[ ]+${'./src'}
23+
[ ]+${'./src'} --> ${'./src/img.jpg'}
2424
[ ]+FOUND$
2525
`;
2626

test/cases/root-relative-asset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const {
2020

2121
const assertDebugMessages = assertStdout('debug')(1)`
2222
^resolve-url-loader:[^:]+:[ ]*${'/images/img.jpg'}
23-
[ ]+${'.'}
23+
[ ]+${'.'} --> ${'./images/img.jpg'}
2424
[ ]+FOUND$
2525
`;
2626

test/cases/selector-in-directive.postcss.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ const {
2222
const assertDebugMessages = sequence(
2323
assertStdout('debug')(4)`
2424
^resolve-url-loader:[^:]+:[ ]*${'../fonts/font.'}\w+
25-
[ ]+${'./src/feature'}
25+
[ ]+${'./src/feature'} --> ${'./src/fonts/font.'}\w+
2626
[ ]+FOUND$
2727
`,
2828
assertStdout('debug')(1)`
2929
^resolve-url-loader:[^:]+:[ ]*${'images/img.jpg'}
30-
[ ]+${'./src'}
30+
[ ]+${'./src'} --> ${'./src/images/img.jpg'}
3131
[ ]+FOUND$
3232
`
3333
);

test/cases/shallow-asset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const {
2020

2121
const assertDebugMessages = assertStdout('debug')(1)`
2222
^resolve-url-loader:[^:]+:[ ]*${'../images/img.jpg'}
23-
[ ]+${'./src/feature'}
23+
[ ]+${'./src/feature'} --> ${'./src/images/img.jpg'}
2424
[ ]+FOUND$
2525
`;
2626

0 commit comments

Comments
 (0)