|
| 1 | +import {UnitTestTree} from '@angular-devkit/schematics/testing'; |
| 2 | +import {createTestCaseSetup} from '@angular/cdk/schematics/testing'; |
| 3 | +import {join} from 'path'; |
| 4 | +import {MIGRATION_PATH} from '../../../paths'; |
| 5 | + |
| 6 | +const PROJECT_ROOT_DIR = '/projects/cdk-testing'; |
| 7 | +const THEME_FILE_PATH = join(PROJECT_ROOT_DIR, 'src/theme.scss'); |
| 8 | +const TS_FILE_PATH = join(PROJECT_ROOT_DIR, 'src/app/app.component.ts'); |
| 9 | + |
| 10 | +describe('v15 legacy components migration', () => { |
| 11 | + let tree: UnitTestTree; |
| 12 | + |
| 13 | + /** Writes an array of lines as a single file. */ |
| 14 | + let writeLines: (path: string, lines: string[]) => void; |
| 15 | + |
| 16 | + /** Reads a file and split it into an array where each item is a new line. */ |
| 17 | + let splitFile: (path: string) => string[]; |
| 18 | + |
| 19 | + /** Runs the v15 migration on the test application. */ |
| 20 | + let runMigration: () => Promise<{logOutput: string}>; |
| 21 | + |
| 22 | + beforeEach(async () => { |
| 23 | + const testSetup = await createTestCaseSetup('migration-v15', MIGRATION_PATH, []); |
| 24 | + tree = testSetup.appTree; |
| 25 | + runMigration = testSetup.runFixers; |
| 26 | + splitFile = (path: string) => tree.readContent(path).split('\n'); |
| 27 | + writeLines = (path: string, lines: string[]) => testSetup.writeFile(path, lines.join('\n')); |
| 28 | + }); |
| 29 | + |
| 30 | + describe('typescript migrations', () => { |
| 31 | + it('should do nothing yet', async () => { |
| 32 | + writeLines(TS_FILE_PATH, [' ']); |
| 33 | + await runMigration(); |
| 34 | + expect(splitFile(TS_FILE_PATH)).toEqual([' ']); |
| 35 | + }); |
| 36 | + }); |
| 37 | + |
| 38 | + describe('style migrations', () => { |
| 39 | + it('should do nothing yet', async () => { |
| 40 | + writeLines(THEME_FILE_PATH, [' ']); |
| 41 | + await runMigration(); |
| 42 | + expect(splitFile(THEME_FILE_PATH)).toEqual([' ']); |
| 43 | + }); |
| 44 | + }); |
| 45 | +}); |
0 commit comments