From d9fc664d41a6045b117f873febf0c0f30695bdb3 Mon Sep 17 00:00:00 2001 From: Jeremias Peier Date: Tue, 1 Mar 2022 10:10:29 +0100 Subject: [PATCH] test(material/schematics): fix ng-add animations test As `addModuleImportToRootModule` is a void function, the test expectations in its result (value undefined) using '.not' would always be true. This change reads the file content and therefore gives the test its sense. --- src/material/schematics/ng-add/index.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/material/schematics/ng-add/index.spec.ts b/src/material/schematics/ng-add/index.spec.ts index 7d686f56609d..858f73a14ea8 100644 --- a/src/material/schematics/ng-add/index.spec.ts +++ b/src/material/schematics/ng-add/index.spec.ts @@ -239,13 +239,15 @@ describe('ng-add schematic', () => { // Simulate the case where a developer uses `ng-add` on an Angular CLI project which already // explicitly uses the `BrowserAnimationsModule`. It would be wrong to forcibly change // to noop animations. - const fileContent = addModuleImportToRootModule( + addModuleImportToRootModule( appTree, 'BrowserAnimationsModule', '@angular/platform-browser/animations', project, ); + const fileContent = getFileContent(appTree, '/projects/material/src/app/app.module.ts'); + expect(fileContent).not.toContain( 'NoopAnimationsModule', 'Expected the project app module to not import the "NoopAnimationsModule".',