Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

586 B
Raw Blame
import { expect, it } from "vite-plus/test";
import { BACKUP_CODE_ALPHABET, generateBackupCodes } from "./backup-codes";

it("makes ten distinct codes in two groups of five, from capitals and digits that don't look alike", () => {
	const codes = generateBackupCodes();
	expect(codes).toHaveLength(10);
	expect(new Set(codes).size).toBe(10);
	for (const code of codes) {
		expect(code).toMatch(/^[A-Z0-9]{5}-[A-Z0-9]{5}$/);
		for (const character of code.replace("-", "")) expect(BACKUP_CODE_ALPHABET).toContain(character);
	}
	expect(BACKUP_CODE_ALPHABET).not.toMatch(/[01OIL8B]/);
});