french-ssn
Version:
🇫🇷 A parser / validator for French Social Security Number
42 lines • 1.98 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Birth_1 = __importDefault(require("./Birth"));
describe("Birth", () => {
describe("approximate date", () => {
const makeDate = (year, month, day) => new Date(Date.UTC(year, month - 1, day)).toISOString();
it("computes approximate birth date", () => {
expect(new Birth_1.default("04", "83", "78551").approximateDate.toISOString()).toBe(makeDate(1983, 4, 16));
});
describe("february", () => {
it("computes approximate birth date", () => {
expect(new Birth_1.default("02", "83", "78551").approximateDate.toISOString()).toBe(makeDate(1983, 2, 15));
});
});
describe("august", () => {
it("computes approximate birth date", () => {
expect(new Birth_1.default("08", "83", "78551").approximateDate.toISOString()).toBe(makeDate(1983, 8, 17));
});
});
describe("month is missing", () => {
it("computes approximate birth date", () => {
expect(new Birth_1.default("20", "83", "99999").approximateDate.toISOString()).toBe(makeDate(1983, 7, 3));
});
});
});
describe("approximate age", () => {
it("computes approximate age", () => {
Date.now = jest.fn(() => new Date("2018-01-02").valueOf());
expect(new Birth_1.default("01", "80", "78551").approximateAge).toBe(38);
});
describe("birthDate is soon to come", () => {
it("adds approximate age", () => {
Date.now = jest.fn(() => new Date("2018-01-02").valueOf());
expect(new Birth_1.default("02", "80", "78551").approximateAge).toBe(37);
});
});
});
});
//# sourceMappingURL=Birth.test.js.map