mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-07-15 16:01:34 -05:00
48 lines
1003 B
TypeScript
48 lines
1003 B
TypeScript
import { describe, expect, test } from "vitest";
|
|
import type { MainWeaponId } from "./types";
|
|
import { filterWeapon } from "./utils";
|
|
|
|
describe("filterWeapon", () => {
|
|
const sBlast = { type: "MAIN" as const, id: 260 as MainWeaponId };
|
|
|
|
test("matches ignoring hyphens (e.g. 's blast' finds 'S-BLAST')", () => {
|
|
expect(
|
|
filterWeapon({
|
|
weapon: sBlast,
|
|
weaponName: "S-BLAST '92",
|
|
searchTerm: "s blast",
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
test("matches with the hyphen still present", () => {
|
|
expect(
|
|
filterWeapon({
|
|
weapon: sBlast,
|
|
weaponName: "S-BLAST '92",
|
|
searchTerm: "s-blast",
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
test("matches ignoring case", () => {
|
|
expect(
|
|
filterWeapon({
|
|
weapon: sBlast,
|
|
weaponName: "S-BLAST '92",
|
|
searchTerm: "SBLAST",
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
test("does not match unrelated weapon", () => {
|
|
expect(
|
|
filterWeapon({
|
|
weapon: sBlast,
|
|
weaponName: "S-BLAST '92",
|
|
searchTerm: "splattershot",
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
});
|