(testConfig: TestConfigOption = DEFAULT_TEST_CONFIG_OPTION)
| 77 | * Given a config generate an array of test variants. |
| 78 | */ |
| 79 | export const configs = (testConfig: TestConfigOption = DEFAULT_TEST_CONFIG_OPTION): TestUtilities[] => { |
| 80 | const { modes, directions } = testConfig; |
| 81 | |
| 82 | const configs: TestConfig[] = []; |
| 83 | |
| 84 | /** |
| 85 | * If certain options are not provided, |
| 86 | * fall back to the defaults. |
| 87 | */ |
| 88 | const processedMode = modes ?? DEFAULT_MODES; |
| 89 | const processedDirection = directions ?? DEFAULT_DIRECTIONS; |
| 90 | const processedPalette = testConfig.palettes ?? DEFAULT_PALETTES; |
| 91 | |
| 92 | processedMode.forEach((mode) => { |
| 93 | processedDirection.forEach((direction) => { |
| 94 | processedPalette.forEach((palette) => { |
| 95 | configs.push({ mode, direction, palette }); |
| 96 | }); |
| 97 | }); |
| 98 | }); |
| 99 | |
| 100 | return configs.map((config) => { |
| 101 | return { |
| 102 | config, |
| 103 | title: (title: string) => generateTitle(title, config), |
| 104 | screenshot: (fileName: string) => generateScreenshotName(fileName, config), |
| 105 | }; |
| 106 | }); |
| 107 | }; |
| 108 | |
| 109 | const DEFAULT_MODES: Mode[] = ['ios', 'md']; |
| 110 | const DEFAULT_DIRECTIONS: Direction[] = ['ltr', 'rtl']; |
no test coverage detected