french-ssn
Version:
🇫🇷 A parser / validator for French Social Security Number
22 lines • 886 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const pad_1 = __importDefault(require("./pad"));
it("adds missing zeros", () => {
expect((0, pad_1.default)(2, 5)).toBe("00002");
expect((0, pad_1.default)(45, 2)).toBe("45");
});
it("allows strings with leading zeros", () => {
expect((0, pad_1.default)("089", 3)).toBe("089");
});
it("works for powers of 10", () => {
expect((0, pad_1.default)(1, 2)).toBe("01");
expect((0, pad_1.default)(10, 2)).toBe("10");
});
it("throws on input that is not a number or a string", () => {
// @ts-expect-error this is to test a pure JS behavior
expect(() => (0, pad_1.default)(undefined, 2)).toThrow("Cannot pad");
});
//# sourceMappingURL=pad.test.js.map