alsatian
Version:
TypeScript and JavaScript testing framework for beautiful and readable tests
37 lines • 1.31 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const _metadata_keys_1 = require("./_metadata-keys");
const unused_1 = require("../unused");
const mark_property_as_test_1 = require("./mark-property-as-test");
function GetTestCases(caseArguments) {
if (null === caseArguments || undefined === caseArguments) {
return [];
}
if (caseArguments instanceof Function) {
return GetTestCases(caseArguments());
}
if (caseArguments instanceof Array) {
return [...caseArguments];
}
else {
return Array.from(caseArguments);
}
}
function TestCases(caseArguments) {
return (target, propertyKey, descriptor) => {
unused_1.Unused(descriptor);
mark_property_as_test_1.markPropertyAsTest(propertyKey, target);
const testCases = GetTestCases(caseArguments).reduce((acc, val) => {
return [
...acc,
{
caseArguments: val
}
];
}, Reflect.getMetadata(_metadata_keys_1.TEST_CASES, target, propertyKey) || []);
Reflect.defineMetadata(_metadata_keys_1.TEST_CASES, testCases, target, propertyKey);
};
}
exports.TestCases = TestCases;
//# sourceMappingURL=test-cases-decorator.js.map
;