@kilterset/auth0-actions-testing
Version:
Test and develop Auth0 Actions or Okta CIC Actions locally.
44 lines • 2.41 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = __importDefault(require("node:test"));
const mock_1 = require("../../mock");
const node_assert_1 = require("node:assert");
(0, node_test_1.default)("authentication mock", (t) => __awaiter(void 0, void 0, void 0, function* () {
yield t.test("has sensible defaults", () => {
const { methods, riskAssessment } = (0, mock_1.authentication)();
const firstMethod = methods[0];
(0, node_assert_1.ok)(firstMethod, "methods is empty");
(0, node_assert_1.ok)(firstMethod.name, "method name is empty");
(0, node_assert_1.ok)(riskAssessment, "riskAssessment is missing");
try {
new Date(firstMethod.timestamp);
}
catch (_a) {
(0, node_assert_1.fail)("timestamp is not a date");
}
});
yield t.test("can have a number of methods", () => {
const { methods } = (0, mock_1.authentication)({}, { numMethods: 3 });
(0, node_assert_1.strictEqual)(methods.length, 3, "wrong number of methods");
});
yield t.test("can have zero methods", () => {
const { methods } = (0, mock_1.authentication)({}, { numMethods: 0 });
(0, node_assert_1.strictEqual)(methods.length, 0, "expected no methods");
});
yield t.test("raises an error if both methods and numMethods are set", () => {
(0, node_assert_1.throws)(() => (0, mock_1.authentication)({ methods: [] }, { numMethods: 1 }), /specify only one/i);
});
}));
//# sourceMappingURL=authentication.test.js.map