diff --git a/packages/bazel/src/app/schema.json b/packages/bazel/src/app/schema.json index 26257b4548b37..6c4fb431259ec 100644 --- a/packages/bazel/src/app/schema.json +++ b/packages/bazel/src/app/schema.json @@ -31,8 +31,7 @@ "viewEncapsulation": { "description": "Specifies the view encapsulation strategy.", "enum": ["Emulated", "Native", "None"], - "type": "string", - "default": "None" + "type": "string" }, "changeDetection": { "description": "Specifies the change detection strategy.", diff --git a/packages/schematics/src/collection/app/app.spec.ts b/packages/schematics/src/collection/app/app.spec.ts index dec6c3421f0da..9f9a3d1be7e46 100644 --- a/packages/schematics/src/collection/app/app.spec.ts +++ b/packages/schematics/src/collection/app/app.spec.ts @@ -148,4 +148,25 @@ describe('app', () => { ); }); }); + + describe('view encapsulation', () => { + it('should not set Component encapsulation metadata if option flag not included', () => { + const tree = schematicRunner.runSchematic( + 'app', + { name: 'myApp', npmScope: 'nrwl', directory: 'myDir' }, + appTree + ); + expect(getFileContent(tree, 'apps/my-dir/my-app/src/app/app.component.ts')).not.toContain('encapsulation: '); + }); + it('should set Component encapsulation metadata if option flag is included', () => { + const tree = schematicRunner.runSchematic( + 'app', + { name: 'myApp', npmScope: 'nrwl', directory: 'myDir', viewEncapsulation: 'Native' }, + appTree + ); + expect(getFileContent(tree, 'apps/my-dir/my-app/src/app/app.component.ts')).toContain( + 'encapsulation: ViewEncapsulation.Native' + ); + }); + }); }); diff --git a/packages/schematics/src/collection/app/schema.json b/packages/schematics/src/collection/app/schema.json index 70f093fe4802e..8d279e3d2436a 100644 --- a/packages/schematics/src/collection/app/schema.json +++ b/packages/schematics/src/collection/app/schema.json @@ -36,8 +36,7 @@ "viewEncapsulation": { "description": "Specifies the view encapsulation strategy.", "enum": ["Emulated", "Native", "None"], - "type": "string", - "default": "None" + "type": "string" }, "changeDetection": { "description": "Specifies the change detection strategy.",