diff --git a/src/material/schematics/ng-add/index.spec.ts b/src/material/schematics/ng-add/index.spec.ts index f54a62b1ea09..3c1422e4528b 100644 --- a/src/material/schematics/ng-add/index.spec.ts +++ b/src/material/schematics/ng-add/index.spec.ts @@ -387,4 +387,27 @@ describe('ng-add schematic', () => { expect(buffer.toString()).toContain(''); }); }); + + it('should not add the global typography class if the user did not opt into it', async () => { + appTree.overwrite('projects/material/src/index.html', ` + + + + + `); + + const tree = await runner.runSchematicAsync('ng-add-setup-project', { + typography: false + }, appTree).toPromise(); + + const workspace = getWorkspace(tree); + const project = getProjectFromWorkspace(workspace); + const indexFiles = getProjectIndexFiles(project); + expect(indexFiles.length).toBe(1); + + indexFiles.forEach(indexPath => { + const buffer = tree.read(indexPath)!; + expect(buffer.toString()).toContain(''); + }); + }); }); diff --git a/src/material/schematics/ng-add/theming/theming.ts b/src/material/schematics/ng-add/theming/theming.ts index 45968ca6f642..37328b452522 100644 --- a/src/material/schematics/ng-add/theming/theming.ts +++ b/src/material/schematics/ng-add/theming/theming.ts @@ -57,7 +57,9 @@ export function addTypographyClass(options: Schema): (host: Tree) => Tree { throw new SchematicsException('No project index HTML file could be found.'); } - projectIndexFiles.forEach(indexFilePath => addBodyClass(host, indexFilePath, 'mat-typography')); + if (options.typography) { + projectIndexFiles.forEach(path => addBodyClass(host, path, 'mat-typography')); + } return host; };