diff --git a/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts b/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts index b55eb051ac..c633e3eb3a 100644 --- a/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts +++ b/modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts @@ -4,7 +4,7 @@ export enum <%= classify(name) %>ActionTypes { Load<%= classify(name) %>s = '[<%= classify(name) %>] Load <%= classify(name) %>s' } -export class <%= classify(name) %> implements Action { +export class Load<%= classify(name) %>s implements Action { readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s; } diff --git a/modules/schematics/src/action/index.spec.ts b/modules/schematics/src/action/index.spec.ts index 3e77c1a44a..fc178c06ca 100644 --- a/modules/schematics/src/action/index.spec.ts +++ b/modules/schematics/src/action/index.spec.ts @@ -69,6 +69,32 @@ describe('Action Schematic', () => { expect(fileContent).toMatch(/export enum FooActionTypes/); }); + it('should create a class based on the provided name', () => { + const tree = schematicRunner.runSchematic( + 'action', + defaultOptions, + appTree + ); + const fileContent = tree.readContent( + `${projectPath}/src/app/foo.actions.ts` + ); + + expect(fileContent).toMatch(/export class LoadFoos implements Action/); + }); + + it('should create the union type based on the provided name', () => { + const tree = schematicRunner.runSchematic( + 'action', + defaultOptions, + appTree + ); + const fileContent = tree.readContent( + `${projectPath}/src/app/foo.actions.ts` + ); + + expect(fileContent).toMatch(/export type FooActions = LoadFoos/); + }); + it('should group within an "actions" folder if group is set', () => { const tree = schematicRunner.runSchematic( 'action',