diff --git a/src/lib/features/playground/generateObjectCombinations.test.ts b/src/lib/features/playground/generateObjectCombinations.test.ts index 81cd72a122..e21356a594 100644 --- a/src/lib/features/playground/generateObjectCombinations.test.ts +++ b/src/lib/features/playground/generateObjectCombinations.test.ts @@ -5,15 +5,16 @@ test('should generate all combinations correctly', () => { sessionId: '1,2', appName: 'a,b,c', channels: 'internet', + nonString: 1, }; 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' }, + { 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); diff --git a/src/lib/features/playground/generateObjectCombinations.ts b/src/lib/features/playground/generateObjectCombinations.ts index fe0a3aebc0..78c1f073df 100644 --- a/src/lib/features/playground/generateObjectCombinations.ts +++ b/src/lib/features/playground/generateObjectCombinations.ts @@ -1,13 +1,16 @@ type Dict = { [K in keyof T]: string[] }; -export const splitByComma = >( +export const splitByComma = >( obj: T, ): Dict => Object.fromEntries( - Object.entries(obj).map(([key, value]) => [key, value.split(',')]), + Object.entries(obj).map(([key, value]) => [ + key, + typeof value === 'string' ? value.split(',') : [value], + ]), ) as Dict; -export const generateCombinations = >( +export const generateCombinations = >( obj: Dict, ): T[] => { const keys = Object.keys(obj) as (keyof T)[];