mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
|
import { generateObjectCombinations } from './generateObjectCombinations';
|
||
|
|
||
|
test('should generate all combinations correctly', () => {
|
||
|
const obj = {
|
||
|
sessionId: '1,2',
|
||
|
appName: 'a,b,c',
|
||
|
channels: 'internet',
|
||
|
};
|
||
|
|
||
|
const expectedCombinations = [
|
||
|
{ sessionId: '1', appName: 'a', channels: 'internet' },
|
||
|
{ sessionId: '1', appName: 'b', channels: 'internet' },
|
||
|
{ sessionId: '1', appName: 'c', channels: 'internet' },
|
||
|
{ sessionId: '2', appName: 'a', channels: 'internet' },
|
||
|
{ sessionId: '2', appName: 'b', channels: 'internet' },
|
||
|
{ sessionId: '2', appName: 'c', channels: 'internet' },
|
||
|
];
|
||
|
|
||
|
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);
|
||
|
});
|