|
7 | 7 | */
|
8 | 8 | import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
|
9 | 9 | import { Schema as ApplicationOptions, Style } from '../application/schema';
|
| 10 | +import { NodeDependencyType, addPackageJsonDependency } from '../utility/dependencies'; |
10 | 11 | import { Schema as WorkspaceOptions } from '../workspace/schema';
|
11 | 12 | import { Schema as UniversalOptions } from './schema';
|
12 | 13 |
|
@@ -227,4 +228,25 @@ describe('Universal Schematic', () => {
|
227 | 228 | expect(tree.exists(filePath)).toEqual(true);
|
228 | 229 | });
|
229 | 230 |
|
| 231 | + it(`should not add import to '@angular/localize' in main file when it's not a depedency`, async () => { |
| 232 | + const tree = await schematicRunner.runSchematicAsync('universal', defaultOptions, appTree) |
| 233 | + .toPromise(); |
| 234 | + const filePath = '/projects/bar/src/main.server.ts'; |
| 235 | + const contents = tree.readContent(filePath); |
| 236 | + expect(contents).not.toContain('@angular/localize'); |
| 237 | + }); |
| 238 | + |
| 239 | + it(`should add import to '@angular/localize' in main file when it's a depedency`, async () => { |
| 240 | + addPackageJsonDependency(appTree, { |
| 241 | + name: '@angular/localize', |
| 242 | + type: NodeDependencyType.Default, |
| 243 | + version: 'latest', |
| 244 | + }); |
| 245 | + |
| 246 | + const tree = await schematicRunner.runSchematicAsync('universal', defaultOptions, appTree) |
| 247 | + .toPromise(); |
| 248 | + const filePath = '/projects/bar/src/main.server.ts'; |
| 249 | + const contents = tree.readContent(filePath); |
| 250 | + expect(contents).toContain('@angular/localize/init'); |
| 251 | + }); |
230 | 252 | });
|
0 commit comments