( versionName: string, collectionFile: string, inputFiles: string[] | undefined, )
| 176 | * spec definitions. This should be used within a "describe" jasmine closure. |
| 177 | */ |
| 178 | export function defineJasmineTestCases( |
| 179 | versionName: string, |
| 180 | collectionFile: string, |
| 181 | inputFiles: string[] | undefined, |
| 182 | ) { |
| 183 | // No test cases for the given version are available. Skip setting up tests for that |
| 184 | // version. |
| 185 | if (!inputFiles) { |
| 186 | // Jasmine throws an error if there's a `describe` without any tests. |
| 187 | it('should pass', () => {}); |
| 188 | return; |
| 189 | } |
| 190 | |
| 191 | let appTree: UnitTestTree; |
| 192 | let testCasesOutputPath: string; |
| 193 | |
| 194 | beforeAll(async () => { |
| 195 | const {appTree: _tree, runFixers} = await createTestCaseSetup( |
| 196 | `migration-${versionName}`, |
| 197 | collectionFile, |
| 198 | inputFiles, |
| 199 | ); |
| 200 | |
| 201 | await runFixers(); |
| 202 | |
| 203 | appTree = _tree; |
| 204 | testCasesOutputPath = '/projects/cdk-testing/src/test-cases/'; |
| 205 | }); |
| 206 | |
| 207 | // Iterates through every test case directory and generates a jasmine test block that will |
| 208 | // verify that the update schematics properly updated the test input to the expected output. |
| 209 | inputFiles.forEach(inputFile => { |
| 210 | const inputTestName = basename(inputFile, extname(inputFile)); |
| 211 | |
| 212 | it(`should apply update schematics to test case: ${inputTestName}`, () => { |
| 213 | expect(appTree.readContent(join(testCasesOutputPath, `${inputTestName}.ts`))).toBe( |
| 214 | readFileContent(inputFile.replace(TEST_CASE_INPUT_SUFFIX, TEST_CASE_OUTPUT_SUFFIX)), |
| 215 | ); |
| 216 | }); |
| 217 | }); |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Patches the specified virtual file system tree to be able to read the TypeScript |
no test coverage detected