1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00
unleash.unleash/src/lib/features/playground/generateObjectCombinations.test.ts

40 lines
1.3 KiB
TypeScript
Raw Normal View History

import { generateObjectCombinations } from './generateObjectCombinations';
test('should generate all combinations correctly', () => {
const obj = {
sessionId: '1,2',
appName: 'a,b,c',
channels: 'internet',
nonString: 1,
};
const expectedCombinations = [
{ sessionId: '1', appName: 'a', channels: 'internet', nonString: 1 },
{ sessionId: '1', appName: 'b', channels: 'internet', nonString: 1 },
{ sessionId: '1', appName: 'c', channels: 'internet', nonString: 1 },
{ sessionId: '2', appName: 'a', channels: 'internet', nonString: 1 },
{ sessionId: '2', appName: 'b', channels: 'internet', nonString: 1 },
{ sessionId: '2', appName: 'c', channels: 'internet', nonString: 1 },
];
const actualCombinations = generateObjectCombinations(obj);
expect(actualCombinations).toEqual(expectedCombinations);
});
test('should generate all combinations correctly when only one combination', () => {
const obj = {
sessionId: '1',
appName: 'a',
channels: 'internet',
};
const expectedCombinations = [
{ sessionId: '1', appName: 'a', channels: 'internet' },
];
const actualCombinations = generateObjectCombinations(obj);
expect(actualCombinations).toEqual(expectedCombinations);
});