40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { loadSets, getCards, Database, initDB, cardFullName } from "@/mlpccg";
|
|
import { setupIDBShim } from "@/testing";
|
|
|
|
setupIDBShim();
|
|
|
|
describe("mlpccg/Database", () => {
|
|
beforeAll(async () => {
|
|
jest.setTimeout(15000);
|
|
await initDB();
|
|
await loadSets();
|
|
});
|
|
|
|
test("getCards without a filter returns all the cards", async () => {
|
|
expect(Database).toBeTruthy();
|
|
const allCards = await Database!.cards.count();
|
|
const filtered = await getCards({});
|
|
expect(filtered).toHaveLength(allCards);
|
|
});
|
|
|
|
test("getCards with a primary filter filters card correctly", async () => {
|
|
expect(Database).toBeTruthy();
|
|
const filtered = await getCards({
|
|
Types: ["Troublemaker"]
|
|
});
|
|
for (const card of filtered) {
|
|
expect(card.Type).toBe("Troublemaker");
|
|
}
|
|
});
|
|
|
|
test("getCards with a secondary filter filters card correctly", async () => {
|
|
expect(Database).toBeTruthy();
|
|
const filtered = await getCards({
|
|
Name: "Rainbow Dash"
|
|
});
|
|
for (const card of filtered) {
|
|
expect(cardFullName(card).indexOf("Rainbow Dash") >= 0).toBeTruthy();
|
|
}
|
|
});
|
|
});
|