mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-10 09:43:10 +00:00
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { expect } from 'chai';
|
|
|
|
import { getPseudoRandomSubset } from './discovery';
|
|
|
|
describe('Discovery', () => {
|
|
it('returns all values when wanted number matches available values', function () {
|
|
const values = ['a', 'b', 'c'];
|
|
|
|
const res = getPseudoRandomSubset(values, 3);
|
|
|
|
expect(res.length).to.eq(3);
|
|
expect(res.includes('a')).to.be.true;
|
|
expect(res.includes('b')).to.be.true;
|
|
expect(res.includes('c')).to.be.true;
|
|
});
|
|
|
|
it('returns all values when wanted number is greater than available values', function () {
|
|
const values = ['a', 'b', 'c'];
|
|
|
|
const res = getPseudoRandomSubset(values, 5);
|
|
|
|
expect(res.length).to.eq(3);
|
|
expect(res.includes('a')).to.be.true;
|
|
expect(res.includes('b')).to.be.true;
|
|
expect(res.includes('c')).to.be.true;
|
|
});
|
|
|
|
it('returns a subset of values when wanted number is lesser than available values', function () {
|
|
const values = ['a', 'b', 'c'];
|
|
|
|
const res = getPseudoRandomSubset(values, 2);
|
|
|
|
expect(res.length).to.eq(2);
|
|
});
|
|
});
|