diff --git a/packages/schematics/angular/class/files/__name@dasherize__.__type__.spec.ts.template b/packages/schematics/angular/class/files/__name@dasherize__.__type__.spec.ts.template index 08d01001aa98..976e5dbba0af 100644 --- a/packages/schematics/angular/class/files/__name@dasherize__.__type__.spec.ts.template +++ b/packages/schematics/angular/class/files/__name@dasherize__.__type__.spec.ts.template @@ -1,4 +1,4 @@ -import { <%= classify(name) %> } from './<%= dasherize(name) %><%= type %>'; +import { <%= classify(name) %> } from './<%= dasherize(name) %><%= type ? '.' + type : '' %>'; describe('<%= classify(name) %>', () => { it('should create an instance', () => { diff --git a/packages/schematics/angular/class/index_spec.ts b/packages/schematics/angular/class/index_spec.ts index df59118b08c9..636cbbb19fc9 100644 --- a/packages/schematics/angular/class/index_spec.ts +++ b/packages/schematics/angular/class/index_spec.ts @@ -74,6 +74,14 @@ describe('Class Schematic', () => { expect(tree.files).toContain('/projects/bar/src/app/foo.model.ts'); }); + it('should import the class from the typed file in the spec file', async () => { + const options = { ...defaultOptions, type: 'model', skipTests: false }; + + const tree = await schematicRunner.runSchematic('class', options, appTree); + const specContent = tree.readContent('/projects/bar/src/app/foo.model.spec.ts'); + expect(specContent).toContain("import { Foo } from './foo.model';"); + }); + it('should split the name to name & type with split on "."', async () => { const options = { ...defaultOptions, name: 'foo.model' }; const tree = await schematicRunner.runSchematic('class', options, appTree);