Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schematics): correct a type of action class generated #1140

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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