webshap
Version:
Explain any ML models anywhere
37 lines (31 loc) • 839 B
text/typescript
import { describe, test, expect, beforeEach } from 'vitest';
import { comb, getCombinations } from '../../src/utils/utils';
test('comb()', () => {
expect(comb(10, 1)).toBe(10);
expect(comb(10, 0)).toBe(1);
expect(comb(10, 0)).toBe(1);
expect(comb(15, 3)).toBe(455);
expect(comb(15, 3)).toBe(455);
expect(comb(25, 18)).toBe(480700);
expect(comb(25, 18)).toBe(480700);
expect(comb(100, 5)).toBe(75287520);
expect(comb(100, 5)).toBe(75287520);
});
test('getCombinations()', () => {
const myArray = [1, 2, 3, 4];
expect(getCombinations(myArray, 2)).toEqual([
[],
[],
[],
[],
[],
[]
]);
expect(getCombinations(myArray, 3)).toEqual([
[],
[],
[],
[]
]);
expect(getCombinations(myArray, 4)).toEqual([[1, 2, 3, 4]]);
});