|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import { getProjectFromWorkspace, getProjectTargetOptions } from '@angular/cdk/schematics'; |
7 | | -import { firstValueFrom } from 'rxjs'; |
8 | 7 |
|
9 | 8 | import { normalize } from '@angular-devkit/core'; |
10 | 9 | import { WorkspaceDefinition } from '@angular-devkit/core/src/workspace'; |
11 | 10 | import { Tree } from '@angular-devkit/schematics'; |
12 | 11 | import { NodePackageName } from '@angular-devkit/schematics/tasks/package-manager/options'; |
13 | 12 | import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; |
14 | | -import { addRootImport } from '@schematics/angular/utility'; |
15 | 13 | import { getWorkspace } from '@schematics/angular/utility/workspace'; |
16 | 14 |
|
17 | 15 | import { join } from 'path'; |
@@ -132,69 +130,29 @@ describe('[standalone] ng-add schematic', () => { |
132 | 130 | expect(assetsString).toContain(iconPathSegment); |
133 | 131 | }); |
134 | 132 |
|
135 | | - it('should required modules', async () => { |
| 133 | + it('should required modules and providers', async () => { |
136 | 134 | const options = { ...defaultOptions }; |
137 | 135 | const tree = await runner.runSchematic('ng-add-setup-project', options, appTree); |
138 | 136 | const fileContent = getFileContent(tree, '/projects/ng-zorro/src/app/app.config.ts'); |
139 | 137 |
|
| 138 | + expect(fileContent).toContain('provideHttpClient()'); |
140 | 139 | expect(fileContent).toContain('FormsModule'); |
141 | | - expect(fileContent).toContain('HttpClientModule'); |
142 | 140 | }); |
143 | 141 |
|
144 | | - it('should add browserAnimationsModuleName if animations is enable', async () => { |
| 142 | + it('should add provideAnimationsAsync() call function if animations is enable', async () => { |
145 | 143 | const options = { ...defaultOptions, animations: true }; |
146 | 144 | const tree = await runner.runSchematic('ng-add-setup-project', options, appTree); |
147 | 145 | const fileContent = getFileContent(tree, '/projects/ng-zorro/src/app/app.config.ts'); |
148 | 146 |
|
149 | | - expect(fileContent).toContain('provideAnimations'); |
| 147 | + expect(fileContent).toContain('provideAnimationsAsync()'); |
150 | 148 | }); |
151 | 149 |
|
152 | | - it('should add noopAnimationsModuleName if animations is disable', async () => { |
| 150 | + it(`should add provideAnimationsAsync('noop') function call if animations is disable`, async () => { |
153 | 151 | const options = { ...defaultOptions, animations: false }; |
154 | 152 | const tree = await runner.runSchematic('ng-add-setup-project', options, appTree); |
155 | 153 | const fileContent = getFileContent(tree, '/projects/ng-zorro/src/app/app.config.ts'); |
156 | 154 |
|
157 | | - expect(fileContent).toContain('provideNoopAnimations'); |
158 | | - }); |
159 | | - |
160 | | - it('should not add BrowserAnimationsModule if NoopAnimationsModule is set up', async () => { |
161 | | - const options = { ...defaultOptions, animations: true }; |
162 | | - |
163 | | - // Add NoopAnimationsModule |
164 | | - await firstValueFrom( |
165 | | - runner.callRule( |
166 | | - addRootImport(options.project, ({ code, external }) => { |
167 | | - return code`${external('NoopAnimationsModule', '@angular/platform-browser/animations')}`; |
168 | | - }), |
169 | | - appTree |
170 | | - ) |
171 | | - ); |
172 | | - |
173 | | - const tree = await runner.runSchematic('ng-add-setup-project', options, appTree); |
174 | | - const fileContent = getFileContent(tree, '/projects/ng-zorro/src/app/app.config.ts'); |
175 | | - |
176 | | - expect(fileContent).toContain('NoopAnimationsModule'); |
177 | | - expect(fileContent).not.toContain('BrowserAnimationsModule'); |
178 | | - }); |
179 | | - |
180 | | - it('should not add NoopAnimationsModule if BrowserAnimationsModule is set up', async () => { |
181 | | - const options = { ...defaultOptions, animations: false }; |
182 | | - |
183 | | - // import BrowserAnimationsModule |
184 | | - await firstValueFrom( |
185 | | - runner.callRule( |
186 | | - addRootImport(options.project, ({ code, external }) => { |
187 | | - return code`${external('BrowserAnimationsModule', '@angular/platform-browser/animations')}`; |
188 | | - }), |
189 | | - appTree |
190 | | - ) |
191 | | - ); |
192 | | - |
193 | | - const tree = await runner.runSchematic('ng-add-setup-project', options, appTree); |
194 | | - const fileContent = getFileContent(tree, '/projects/ng-zorro/src/app/app.config.ts'); |
195 | | - |
196 | | - expect(fileContent).not.toContain('NoopAnimationsModule'); |
197 | | - expect(fileContent).toContain('BrowserAnimationsModule'); |
| 155 | + expect(fileContent).toContain(`provideAnimationsAsync('noop')`); |
198 | 156 | }); |
199 | 157 |
|
200 | 158 | it('should register default locale id', async () => { |
|
0 commit comments