Skip to content

Commit 0677c6e

Browse files
committed
Add options.plugins schema validatio: Move away from error parsing to comparing the whole message
1 parent 70c50ea commit 0677c6e

File tree

1 file changed

+54
-30
lines changed

1 file changed

+54
-30
lines changed

test/Validation.test.js

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,16 @@ describe("Validation", () => {
263263
false
264264
]
265265
},
266-
test(err) {
267-
err.message.should.startWith("Invalid configuration object.");
268-
err.message.split("\n").slice(1)[0].should.be.eql(
269-
" - configuration.plugins[0] should be one of these:"
270-
);
271-
}
266+
message: [
267+
" - configuration.plugins[0] should be one of these:",
268+
" object { apply, ... } | function",
269+
" -> Plugin of type object or instanceof Function",
270+
" Details:",
271+
" * configuration.plugins[0] should be an object.",
272+
" -> Compiler or Resolver Plugin instance of Function",
273+
" * configuration.plugins[0] should be an instance of function",
274+
" -> Compiler or Resolver Plugin instance of Function"
275+
]
272276
}, {
273277
name: "Invalid plugin provided: array",
274278
config: {
@@ -277,24 +281,32 @@ describe("Validation", () => {
277281
[]
278282
]
279283
},
280-
test(err) {
281-
err.message.should.startWith("Invalid configuration object.");
282-
err.message.split("\n").slice(1)[0].should.be.eql(
283-
" - configuration.plugins[0] should be one of these:"
284-
);
285-
}
284+
message: [
285+
" - configuration.plugins[0] should be one of these:",
286+
" object { apply, ... } | function",
287+
" -> Plugin of type object or instanceof Function",
288+
" Details:",
289+
" * configuration.plugins[0] should be an object.",
290+
" -> Compiler or Resolver Plugin instance of Function",
291+
" * configuration.plugins[0] should be an instance of function",
292+
" -> Compiler or Resolver Plugin instance of Function"
293+
]
286294
}, {
287295
name: "Invalid plugin provided: string",
288296
config: {
289297
entry: "foo.js",
290298
plugins: ["abc123"]
291299
},
292-
test(err) {
293-
err.message.should.startWith("Invalid configuration object.");
294-
err.message.split("\n").slice(1)[0].should.be.eql(
295-
" - configuration.plugins[0] should be one of these:"
296-
);
297-
}
300+
message: [
301+
" - configuration.plugins[0] should be one of these:",
302+
" object { apply, ... } | function",
303+
" -> Plugin of type object or instanceof Function",
304+
" Details:",
305+
" * configuration.plugins[0] should be an object.",
306+
" -> Compiler or Resolver Plugin instance of Function",
307+
" * configuration.plugins[0] should be an instance of function",
308+
" -> Compiler or Resolver Plugin instance of Function"
309+
]
298310
}, {
299311
name: "Invalid plugin provided: int",
300312
config: {
@@ -303,12 +315,16 @@ describe("Validation", () => {
303315
12
304316
]
305317
},
306-
test(err) {
307-
err.message.should.startWith("Invalid configuration object.");
308-
err.message.split("\n").slice(1)[0].should.be.eql(
309-
" - configuration.plugins[0] should be one of these:"
310-
);
311-
}
318+
message: [
319+
" - configuration.plugins[0] should be one of these:",
320+
" object { apply, ... } | function",
321+
" -> Plugin of type object or instanceof Function",
322+
" Details:",
323+
" * configuration.plugins[0] should be an object.",
324+
" -> Compiler or Resolver Plugin instance of Function",
325+
" * configuration.plugins[0] should be an instance of function",
326+
" -> Compiler or Resolver Plugin instance of Function"
327+
]
312328
}, {
313329
name: "Invalid plugin provided: object without apply function",
314330
config: {
@@ -317,12 +333,20 @@ describe("Validation", () => {
317333
new function() {}
318334
]
319335
},
320-
test(err) {
321-
err.message.should.startWith("Invalid configuration object.");
322-
err.message.split("\n").slice(1)[0].should.be.eql(
323-
" - configuration.plugins[0] should be one of these:"
324-
);
325-
}
336+
message: [
337+
" - configuration.plugins[0] should be one of these:",
338+
" object { apply, ... } | function",
339+
" -> Plugin of type object or instanceof Function",
340+
" Details:",
341+
" * configuration.plugins[0] misses the property 'apply'.",
342+
" function",
343+
" -> The run point of the plugin, required method.",
344+
" * configuration.plugins[0] misses the property 'apply'.",
345+
" function",
346+
" -> The run point of the plugin, required method.",
347+
" * configuration.plugins[0] should be an instance of function",
348+
" -> Compiler or Resolver Plugin instance of Function"
349+
]
326350
}];
327351

328352
testCases.forEach((testCase) => {

0 commit comments

Comments
 (0)