mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
remove commented out code dismiss success dialog - onClick was missing locale for add-club url prefer manual entry club if both auto and manual entry versions exist, only if pending = false change manual entry field to a boolean filter out clubs that are pending approval from manual entry add info message on success tournament form adds to DB and send discord message ping discord with club submission details i18n for add club update map to allow coordinate update depending on tournament/club page basic add club form with reusable map component
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
|
|
import { IClub, filterClubsByManualEntry } from "@/utils/clubFilters";
|
|
|
|
import { clubData } from "./helpers/clubData";
|
|
|
|
describe("clubs", () => {
|
|
test("club data is unique", () => {
|
|
const clubDataIds = clubData.map((club) => club._id);
|
|
const originalLength = clubDataIds.length;
|
|
const filteredLength = new Set(clubDataIds).size;
|
|
expect(originalLength).toEqual(filteredLength);
|
|
});
|
|
|
|
test("contains manually entered club non-pending", () => {
|
|
const containsManuallyEnteredClub = clubData.some(
|
|
(club) => club.manual_entry,
|
|
);
|
|
expect(containsManuallyEnteredClub).toBeTruthy;
|
|
});
|
|
|
|
test("manual entered club filters out auto-generated club of same name", () => {
|
|
const duplicateClubNames: Set<string> = new Set(
|
|
clubData.map((club) => club.name),
|
|
);
|
|
|
|
for (const club of clubData) {
|
|
if (duplicateClubNames.has(club.name)) {
|
|
duplicateClubNames.delete(club.name);
|
|
} else {
|
|
duplicateClubNames.add(club.name);
|
|
}
|
|
}
|
|
|
|
const filteredData: IClub[] = filterClubsByManualEntry(clubData);
|
|
|
|
const hasManualEnteredClubs = filteredData.some(
|
|
(club) => club.manual_entry && !club.pending,
|
|
);
|
|
|
|
expect(filteredData.length).toEqual(
|
|
clubData.length - duplicateClubNames.size,
|
|
);
|
|
|
|
expect(hasManualEnteredClubs).toBeTruthy;
|
|
});
|
|
});
|