Skip to content

Commit 7d0a442

Browse files
committed
add two tests for non-absolute and absolute paths check
1 parent 8ccf068 commit 7d0a442

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

test/Validation.test.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,65 @@ describe("Validation", function() {
175175
" * configuration.devtool should be a string.",
176176
" * configuration.devtool should be false"
177177
]
178+
}, {
179+
name: "non-absolute path",
180+
config: {
181+
entry: "foo.js",
182+
output: {
183+
filename: "/bar"
184+
}
185+
},
186+
message: [
187+
" - configuration.output.filename A non-absolut path is expected. However the provided value \"/bar\" is an absolute path!",
188+
" ({",
189+
" \"keyword\": \"absolutePath\",",
190+
" \"params\": {",
191+
" \"absolutePath\": \"/bar\"",
192+
" },",
193+
" \"message\": \"A non-absolut path is expected. However the provided value \\\"/bar\\\" is an absolute path!\\n\",",
194+
" \"parentSchema\": {",
195+
" \"description\": \"Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.\",",
196+
" \"type\": \"string\",",
197+
" \"absolutePath\": false",
198+
" },",
199+
" \"dataPath\": \".output.filename\",",
200+
" \"schemaPath\": \"#/definitions/output/properties/filename/absolutePath\",",
201+
" \"schema\": false,",
202+
" \"data\": \"/bar\"",
203+
" }).",
204+
" string",
205+
" Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files."
206+
]
207+
}, {
208+
name: "absolute path",
209+
config: {
210+
entry: "foo.js",
211+
output: {
212+
filename: "bar"
213+
},
214+
context: "baz"
215+
},
216+
message: [
217+
" - configuration.context The provided value \"baz\" is not an absolute path!",
218+
" ({",
219+
" \"keyword\": \"absolutePath\",",
220+
" \"params\": {",
221+
" \"absolutePath\": \"baz\"",
222+
" },",
223+
" \"message\": \"The provided value \\\"baz\\\" is not an absolute path!\\n\",",
224+
" \"parentSchema\": {",
225+
" \"description\": \"The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory.\",",
226+
" \"type\": \"string\",",
227+
" \"absolutePath\": true",
228+
" },",
229+
" \"dataPath\": \".context\",",
230+
" \"schemaPath\": \"#/properties/context/absolutePath\",",
231+
" \"schema\": true,",
232+
" \"data\": \"baz\"",
233+
" }).",
234+
" string",
235+
" The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory."
236+
]
178237
}];
179238
testCases.forEach(function(testCase) {
180239
it("should fail validation for " + testCase.name, function() {

0 commit comments

Comments
 (0)