|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google Inc. All Rights Reserved. |
| 4 | + * |
| 5 | + * Use of this source code is governed by an MIT-style license that can be |
| 6 | + * found in the LICENSE file at https://angular.io/license |
| 7 | + */ |
| 8 | +import { Tree } from '@angular-devkit/schematics'; |
| 9 | +import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; |
| 10 | +import { readJsonInTree, serializeJson, updateJsonInTree } from './ast-utils'; |
| 11 | + |
| 12 | +describe('Update 8.0.0', () => { |
| 13 | + let initialTree: Tree; |
| 14 | + let schematicRunner: SchematicTestRunner; |
| 15 | + |
| 16 | + beforeEach(() => { |
| 17 | + initialTree = Tree.empty(); |
| 18 | + |
| 19 | + initialTree.create( |
| 20 | + 'package.json', |
| 21 | + serializeJson({ |
| 22 | + devDependencies: { '@angular/cli': '7.1.0', typescript: '~3.1.0' }, |
| 23 | + }), |
| 24 | + ); |
| 25 | + |
| 26 | + schematicRunner = new SchematicTestRunner( |
| 27 | + 'migrations', |
| 28 | + require.resolve('../migration-collection.json'), |
| 29 | + ); |
| 30 | + }); |
| 31 | + |
| 32 | + it('should add vscode extension recommendations', async () => { |
| 33 | + const result = await schematicRunner |
| 34 | + .runSchematicAsync('migration-07', {}, initialTree) |
| 35 | + .toPromise(); |
| 36 | + |
| 37 | + expect(readJsonInTree(result, '.vscode/extensions.json')).toEqual({ |
| 38 | + recommendations: ['angular.ng-template', 'ms-vscode.vscode-typescript-tslint-plugin'], |
| 39 | + }); |
| 40 | + }); |
| 41 | + |
| 42 | + it('should add to existing vscode extension recommendations', async () => { |
| 43 | + initialTree = await schematicRunner |
| 44 | + .callRule( |
| 45 | + updateJsonInTree('.vscode/extensions.json', () => ({ |
| 46 | + recommendations: [ |
| 47 | + 'eamodio.gitlens', 'angular.ng-template', 'ms-vscode.vscode-typescript-tslint-plugin'], |
| 48 | + })), |
| 49 | + initialTree, |
| 50 | + ) |
| 51 | + .toPromise(); |
| 52 | + |
| 53 | + const result = await schematicRunner |
| 54 | + .runSchematicAsync('migration-07', {}, initialTree) |
| 55 | + .toPromise(); |
| 56 | + |
| 57 | + expect(readJsonInTree(result, '.vscode/extensions.json')).toEqual({ |
| 58 | + recommendations: [ |
| 59 | + 'eamodio.gitlens', 'angular.ng-template', 'ms-vscode.vscode-typescript-tslint-plugin'], |
| 60 | + }); |
| 61 | + }); |
| 62 | +}); |
0 commit comments