terrible/app/state/cards.test.js
2024-03-12 11:20:28 -05:00

25 lines
479 B
JavaScript

import {expect} from 'chai';
import {
sample,
} from './cards.js';
const D = 20;
const N = 4000;
const packs = Array.from({length: D})
.map((e, id) => ({
id,
cards: Array.from({length: N}, (e, i) => `${id} - ${i}`),
}));
it('takes valid samples', () => {
const reservoir = sample(packs, N);
expect(reservoir.length)
.to.equal(N);
reservoir.forEach(({pack, card}) => {
expect(packs[pack].cards[card])
.to.equal(`${pack} - ${card}`);
})
});