Basic draft library #19

Merged
hamcha merged 13 commits from feature/draft-lib into master 2019-09-16 13:53:07 +00:00
3 changed files with 18 additions and 3 deletions
Showing only changes of commit ff6a77d431 - Show all commits

View file

@ -2,3 +2,4 @@ export * from "./MockDataConnection";
export * from "./MockPeer"; export * from "./MockPeer";
export * from "./MockHelper"; export * from "./MockHelper";
export * from "./EventHook"; export * from "./EventHook";
export * from "./IDBShim";

View file

@ -1,5 +1,5 @@
import { loadSets, getCards, Database, initDB, cardFullName } from "@/mlpccg"; import { loadSets, getCards, Database, initDB, cardFullName } from "@/mlpccg";
import { setupIDBShim } from "@/testing/IDBShim"; import { setupIDBShim } from "@/testing";
setupIDBShim(); setupIDBShim();

View file

@ -1,6 +1,6 @@
import { setupIDBShim } from "@/testing/IDBShim"; import { setupIDBShim } from "@/testing";
import { initDB, loadSets, Database } from "@/mlpccg"; import { initDB, loadSets, Database } from "@/mlpccg";
import { PackBuilder, spanByRarity } from "@/mlpccg/draft"; import { PackBuilder, spanByRarity, Cube } from "@/mlpccg/draft";
setupIDBShim(); setupIDBShim();
@ -22,4 +22,18 @@ describe("mlpccg/draft", () => {
expect(rarities["R"]).toHaveLength(1); expect(rarities["R"]).toHaveLength(1);
expect(rarities["U"]).toHaveLength(3); expect(rarities["U"]).toHaveLength(3);
}); });
test("Cube can load a newline separated card list", async () => {
expect(Database).toBeTruthy();
const cubeCards = ["ff10", "ff11", "ff12", "ff13", "ff14", "ff15"];
const cubeList = cubeCards.join("\n");
const cube = await Cube.fromList(cubeList);
const builder = new PackBuilder(cube.schema());
const pack = builder.buildPack();
// Pack size should only be 6, since there are not enough cards for a 12 cards pack
expect(pack).toHaveLength(6);
// Make sure pack has ALL the cards from the pool, no duplicates
const sortedPack = pack.map(c => c.ID).sort();
expect(sortedPack).toEqual(cubeCards);
});
}); });