|
1 | 1 | import {SchematicTestRunner} from '@angular-devkit/schematics/testing'; |
| 2 | +import {getProjectFromWorkspace} from '@angular/cdk/schematics'; |
| 3 | +import {getWorkspace} from '@schematics/angular/utility/config'; |
| 4 | +import {getProject} from '@schematics/angular/utility/project'; |
2 | 5 | import {createTestApp, getFileContent} from '../../testing'; |
3 | 6 | import {Schema} from './schema'; |
4 | 7 |
|
@@ -38,17 +41,34 @@ describe('CDK drag-drop schematic', () => { |
38 | 41 | expect(moduleContent).toContain('DragDropModule'); |
39 | 42 | }); |
40 | 43 |
|
41 | | - describe('styleext option', () => { |
| 44 | + describe('style option', () => { |
42 | 45 | it('should respect the option value', () => { |
43 | 46 | const tree = runner.runSchematic( |
44 | | - 'drag-drop', {styleext: 'scss', ...baseOptions}, createTestApp(runner)); |
| 47 | + 'drag-drop', {style: 'scss', ...baseOptions}, createTestApp(runner)); |
| 48 | + |
| 49 | + expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss'); |
| 50 | + }); |
| 51 | + |
| 52 | + it('should respect the deprecated "styleext" option value', () => { |
| 53 | + let tree = createTestApp(runner); |
| 54 | + const workspace = getWorkspace(tree); |
| 55 | + const project = getProjectFromWorkspace(workspace); |
| 56 | + |
| 57 | + // We need to specify the default component options by overwriting |
| 58 | + // the existing workspace configuration because passing the "styleext" |
| 59 | + // option is no longer supported. Though we want to verify that we |
| 60 | + // properly handle old CLI projects which still use the "styleext" option. |
| 61 | + project.schematics!['@schematics/angular:component'] = {styleext: 'scss'}; |
| 62 | + |
| 63 | + tree.overwrite('angular.json', JSON.stringify(workspace)); |
| 64 | + tree = runner.runSchematic('drag-drop', baseOptions, tree); |
45 | 65 |
|
46 | 66 | expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss'); |
47 | 67 | }); |
48 | 68 |
|
49 | 69 | it('should not generate invalid stylesheets', () => { |
50 | 70 | const tree = runner.runSchematic( |
51 | | - 'drag-drop', {styleext: 'styl', ...baseOptions}, createTestApp(runner)); |
| 71 | + 'drag-drop', {style: 'styl', ...baseOptions}, createTestApp(runner)); |
52 | 72 |
|
53 | 73 | // In this case we expect the schematic to generate a plain "css" file because |
54 | 74 | // the component schematics are using CSS style templates which are not compatible |
@@ -99,10 +119,27 @@ describe('CDK drag-drop schematic', () => { |
99 | 119 | }); |
100 | 120 | }); |
101 | 121 |
|
102 | | - describe('spec option', () => { |
| 122 | + describe('skipTests option', () => { |
103 | 123 | it('should respect the option value', () => { |
104 | 124 | const tree = runner.runSchematic( |
105 | | - 'drag-drop', {spec: false, ...baseOptions}, createTestApp(runner)); |
| 125 | + 'drag-drop', {skipTests: true, ...baseOptions}, createTestApp(runner)); |
| 126 | + |
| 127 | + expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts'); |
| 128 | + }); |
| 129 | + |
| 130 | + it('should respect the deprecated global "spec" option value', () => { |
| 131 | + let tree = createTestApp(runner); |
| 132 | + const workspace = getWorkspace(tree); |
| 133 | + const project = getProjectFromWorkspace(workspace); |
| 134 | + |
| 135 | + // We need to specify the default component options by overwriting |
| 136 | + // the existing workspace configuration because passing the "spec" |
| 137 | + // option is no longer supported. Though we want to verify that we |
| 138 | + // properly handle old CLI projects which still use the "spec" option. |
| 139 | + project.schematics!['@schematics/angular:component'] = {spec: false}; |
| 140 | + |
| 141 | + tree.overwrite('angular.json', JSON.stringify(workspace)); |
| 142 | + tree = runner.runSchematic('drag-drop', baseOptions, tree); |
106 | 143 |
|
107 | 144 | expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts'); |
108 | 145 | }); |
|
0 commit comments