Skip to content

Commit

Permalink
fix(schematics): correct a type of action class generated (#1140)
Browse files Browse the repository at this point in the history
  • Loading branch information
koumatsumoto authored and brandonroberts committed Jun 23, 2018
1 parent 6cf99f1 commit bbb7e8c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
26 changes: 26 additions & 0 deletions modules/schematics/src/action/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit bbb7e8c

Please sign in to comment.