From 7d0a442183b151123a4873f59f9325a22b02b388 Mon Sep 17 00:00:00 2001 From: Tim Sebastian Date: Sat, 4 Feb 2017 00:49:38 +1100 Subject: [PATCH] add two tests for non-absolute and absolute paths check --- test/Validation.test.js | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/test/Validation.test.js b/test/Validation.test.js index a30ff3c27..24a5dbb8e 100644 --- a/test/Validation.test.js +++ b/test/Validation.test.js @@ -175,6 +175,65 @@ describe("Validation", function() { " * configuration.devtool should be a string.", " * configuration.devtool should be false" ] + }, { + name: "non-absolute path", + config: { + entry: "foo.js", + output: { + filename: "/bar" + } + }, + message: [ + " - configuration.output.filename A non-absolut path is expected. However the provided value \"/bar\" is an absolute path!", + " ({", + " \"keyword\": \"absolutePath\",", + " \"params\": {", + " \"absolutePath\": \"/bar\"", + " },", + " \"message\": \"A non-absolut path is expected. However the provided value \\\"/bar\\\" is an absolute path!\\n\",", + " \"parentSchema\": {", + " \"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.\",", + " \"type\": \"string\",", + " \"absolutePath\": false", + " },", + " \"dataPath\": \".output.filename\",", + " \"schemaPath\": \"#/definitions/output/properties/filename/absolutePath\",", + " \"schema\": false,", + " \"data\": \"/bar\"", + " }).", + " string", + " 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." + ] + }, { + name: "absolute path", + config: { + entry: "foo.js", + output: { + filename: "bar" + }, + context: "baz" + }, + message: [ + " - configuration.context The provided value \"baz\" is not an absolute path!", + " ({", + " \"keyword\": \"absolutePath\",", + " \"params\": {", + " \"absolutePath\": \"baz\"", + " },", + " \"message\": \"The provided value \\\"baz\\\" is not an absolute path!\\n\",", + " \"parentSchema\": {", + " \"description\": \"The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory.\",", + " \"type\": \"string\",", + " \"absolutePath\": true", + " },", + " \"dataPath\": \".context\",", + " \"schemaPath\": \"#/properties/context/absolutePath\",", + " \"schema\": true,", + " \"data\": \"baz\"", + " }).", + " string", + " The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory." + ] }]; testCases.forEach(function(testCase) { it("should fail validation for " + testCase.name, function() {