48 lines
9.5 KiB
JavaScript
48 lines
9.5 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const chai_1 = require("chai");
|
|
const type_1 = __importDefault(require("./type"));
|
|
function getFn(command) {
|
|
switch (command.assertionType) {
|
|
case type_1.default.eql:
|
|
return () => chai_1.assert.deepEqual(command.actual, command.expected, command.message);
|
|
case type_1.default.notEql:
|
|
return () => chai_1.assert.notDeepEqual(command.actual, command.expected, command.message);
|
|
case type_1.default.ok:
|
|
return () => chai_1.assert.isOk(command.actual, command.message);
|
|
case type_1.default.notOk:
|
|
return () => chai_1.assert.isNotOk(command.actual, command.message);
|
|
case type_1.default.contains:
|
|
return () => chai_1.assert.include(command.actual, command.expected, command.message);
|
|
case type_1.default.notContains:
|
|
return () => chai_1.assert.notInclude(command.actual, command.expected, command.message);
|
|
case type_1.default.typeOf:
|
|
return () => chai_1.assert.typeOf(command.actual, command.expected, command.message);
|
|
case type_1.default.notTypeOf:
|
|
return () => chai_1.assert.notTypeOf(command.actual, command.expected, command.message);
|
|
case type_1.default.gt:
|
|
return () => chai_1.assert.isAbove(command.actual, command.expected, command.message);
|
|
case type_1.default.gte:
|
|
return () => chai_1.assert.isAtLeast(command.actual, command.expected, command.message);
|
|
case type_1.default.lt:
|
|
return () => chai_1.assert.isBelow(command.actual, command.expected, command.message);
|
|
case type_1.default.lte:
|
|
return () => chai_1.assert.isAtMost(command.actual, command.expected, command.message);
|
|
case type_1.default.within:
|
|
return () => (0, chai_1.expect)(command.actual).to.be.within(command.expected, command.expected2, command.message);
|
|
case type_1.default.notWithin:
|
|
return () => (0, chai_1.expect)(command.actual).not.to.be.within(command.expected, command.expected2, command.message);
|
|
case type_1.default.match:
|
|
return () => chai_1.assert.match(command.actual, command.expected, command.message);
|
|
case type_1.default.notMatch:
|
|
return () => chai_1.assert.notMatch(command.actual, command.expected, command.message);
|
|
default:
|
|
return () => void 0;
|
|
}
|
|
}
|
|
exports.default = getFn;
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0LWZuLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2Fzc2VydGlvbnMvZ2V0LWZuLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsK0JBQXNDO0FBQ3RDLGtEQUFvQztBQUdwQyxTQUF3QixLQUFLLENBQUUsT0FBeUI7SUFDcEQsUUFBUSxPQUFPLENBQUMsYUFBYSxFQUFFO1FBQzNCLEtBQUssY0FBYyxDQUFDLEdBQUc7WUFDbkIsT0FBTyxHQUFHLEVBQUUsQ0FBQyxhQUFNLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxNQUFNLEVBQUUsT0FBTyxDQUFDLFFBQVEsRUFBRSxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7UUFFckYsS0FBSyxjQUFjLENBQUMsTUFBTTtZQUN0QixPQUFPLEdBQUcsRUFBRSxDQUFDLGFBQU0sQ0FBQyxZQUFZLENBQUMsT0FBTyxDQUFDLE1BQU0sRUFBRSxPQUFPLENBQUMsUUFBUSxFQUFFLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQztRQUV4RixLQUFLLGNBQWMsQ0FBQyxFQUFFO1lBQ2xCLE9BQU8sR0FBRyxFQUFFLENBQUMsYUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxFQUFFLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQztRQUU5RCxLQUFLLGNBQWMsQ0FBQyxLQUFLO1lBQ3JCLE9BQU8sR0FBRyxFQUFFLENBQUMsYUFBTSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsTUFBTSxFQUFFLE9BQU8sQ0FBQyxPQUFPLENB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