terrible/app/state/cards.test.js

25 lines
479 B
JavaScript
Raw Normal View History

2024-03-11 23:03:35 -05:00
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}`);
})
});