-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed "Utils" from helper file names
renamed variable "version" to "specVersion" in tests Restructure "additionalProperty tests"
- Loading branch information
1 parent
fd1d30d
commit ca974da
Showing
13 changed files
with
201 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const customConfiguration = require("./customConfiguration"); | ||
|
||
/** | ||
* Common test functionality to be able to run the same tests for different types of kind "extension" | ||
*/ | ||
module.exports = { | ||
/** | ||
* Executes the tests for different types of kind extension, e.g. "project-shim", "server-middleware" and "task" | ||
* | ||
* @param {Function} test ava test | ||
* @param {Function} assertValidation assertion function | ||
* @param {string} type one of "project-shim", "server-middleware" and "task" | ||
* @param {Object} additionalConfiguration additional configuration content | ||
*/ | ||
defineTests: function(test, assertValidation, type, additionalConfiguration) { | ||
additionalConfiguration = additionalConfiguration || {}; | ||
additionalConfiguration = Object.assign({"kind": "extension"}, additionalConfiguration); | ||
|
||
customConfiguration.defineTests(test, assertValidation, type, additionalConfiguration); | ||
|
||
["2.0", "2.1"].forEach((specVersion) => { | ||
test(`kind: extension / type: ${type} basic (${specVersion})`, async (t) => { | ||
await assertValidation(t, Object.assign({ | ||
"specVersion": specVersion, | ||
"kind": "extension", | ||
"type": type, | ||
"metadata": { | ||
"name": "my-" + type | ||
} | ||
}, additionalConfiguration)); | ||
}); | ||
|
||
test(`kind: extension / type: ${type} additionalProperties (${specVersion})`, async (t) => { | ||
await assertValidation(t, Object.assign({ | ||
"specVersion": specVersion, | ||
"kind": "extension", | ||
"type": type, | ||
"metadata": { | ||
"name": "my-" + type | ||
}, | ||
"resources": {} | ||
}, additionalConfiguration), [{ | ||
dataPath: "", | ||
keyword: "additionalProperties", | ||
message: "should NOT have additional properties", | ||
params: { | ||
"additionalProperty": "resources" | ||
}, | ||
schemaPath: specVersion === "2.1" ? "#/then/additionalProperties" : "#/else/additionalProperties" | ||
}]); | ||
}); | ||
|
||
test(`${type} Invalid configuration: Additional property (${specVersion})`, async (t) => { | ||
await assertValidation(t, Object.assign( { | ||
"specVersion": specVersion, | ||
"type": type, | ||
"metadata": { | ||
"name": "my-" + type | ||
}, | ||
"notAllowed": true | ||
}, additionalConfiguration), [{ | ||
dataPath: "", | ||
keyword: "additionalProperties", | ||
message: "should NOT have additional properties", | ||
params: { | ||
additionalProperty: "notAllowed", | ||
}, | ||
schemaPath: specVersion === "2.1" ? "#/then/additionalProperties" : "#/else/additionalProperties" | ||
}]); | ||
}); | ||
}); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.