tdt
Version:
Typed Decision Table
78 lines (77 loc) • 1.85 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Basic Example
*
* An example of specifying types when declaring each argument in generateTests.
* In this case, you can benefit from IDE autocompletion when creating arguments.
* If there is an issue with the arguments, an error will occur.
*/
const index_1 = require("../../index");
const domain = {
"Condition": {
"User": {
"IsRegistered": [
"True",
"False"
],
"IsAdmin": [
"True",
"False"
]
},
"Device": [
"Mobile",
"PC"
]
},
"ExpectedResult": [
"Success",
"Failure",
"Any"
]
};
const defaults = {
"Condition": {
"User": {
"IsRegistered": "True",
"IsAdmin": "False"
},
"Device": "Mobile"
},
"ExpectedResult": "Any"
};
const exclusions = [
{
"Condition.User.IsRegistered": "False",
"Condition.User.IsAdmin": "True"
}
];
const perspectives = [
{
"title": "Only registered users accessed from PC can access.",
"constants": {},
"variables": [
"Condition.User.IsRegistered",
"Condition.User.IsAdmin",
"Condition.Device",
],
"expect": (test) => {
if (test["Condition.User.IsRegistered"] === "True" &&
test["Condition.Device"] === "PC") {
test["ExpectedResult"] = "Success";
}
else {
test["ExpectedResult"] = "Failure";
}
return test;
},
}
];
const tests = (0, index_1.generateTests)({
domain,
//defaults,
exclusions,
perspectives,
});
console.log(tests);
;