All files / src/util createTestIds.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                1x       1x 13x 13x    
type TestIds<T extends Readonly<string[]>> = {
  [key in T[number]]: string;
};
 
/**
 * A helper to create scoped test ids across components which can be re-used
 * in e2e and unit tests.
 */
export const createTestIds = <T extends Readonly<string[]>>(
  scope: string,
  ids: T
): TestIds<T> =>
  ids.reduce<Record<string, string>>((acc, curr) => {
    acc[curr] = `${scope}-${curr}`;
    return acc;
  }, {}) as TestIds<T>;