generated from nhcarrigan/template
All checks were successful
Node.js CI / Lint and Test (push) Successful in 41s
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/**
|
|
* @copyright nhcarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
|
|
/* eslint-disable max-nested-callbacks -- Not sure how to better optimise this. */
|
|
|
|
import compare from "string-comparison";
|
|
import { describe, expect, it } from "vitest";
|
|
import { phrases } from "../src/config/phrases.ts";
|
|
|
|
describe("phrases", () => {
|
|
it("should have enough phrases", () => {
|
|
expect.assertions(1);
|
|
expect(phrases.length, "less than 100 phrases").toBeGreaterThan(100);
|
|
});
|
|
|
|
it.each(phrases)(`%s should be unique`, (phrase) => {
|
|
expect.assertions(1);
|
|
const filtered = phrases.filter((p) => {
|
|
return p !== phrase;
|
|
}).map((line) => {
|
|
return line.
|
|
replaceAll("{{ mommy }}", "").
|
|
replaceAll("{{ name }}", "");
|
|
});
|
|
|
|
const matches = compare.levenshtein.sortMatch(phrase.
|
|
replaceAll("{{ mommy }}", "").
|
|
replaceAll("{{ name }}", ""), filtered);
|
|
const closest = matches.reverse()[0];
|
|
expect(closest?.rating, `${phrase} is not unique! Matches ${closest?.member}`).toBeLessThan(0.8);
|
|
});
|
|
});
|