From 25eb713927b9350a6c8559aba331a7927158cc77 Mon Sep 17 00:00:00 2001 From: kouMatsumoto Date: Thu, 21 Jun 2018 16:19:56 +0900 Subject: [PATCH 1/3] fix(schematics): correct an type of action class generated --- .../__name@dasherize__.actions.ts | 2 +- modules/schematics/src/action/index.spec.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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..7de903388a 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 @@ -8,4 +8,4 @@ export class <%= classify(name) %> implements Action { readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s; } -export type <%= classify(name) %>Actions = Load<%= classify(name) %>s; +export type <%= classify(name) %>Actions = <%= classify(name) %>; diff --git a/modules/schematics/src/action/index.spec.ts b/modules/schematics/src/action/index.spec.ts index 3e77c1a44a..f28f938fe6 100644 --- a/modules/schematics/src/action/index.spec.ts +++ b/modules/schematics/src/action/index.spec.ts @@ -69,6 +69,19 @@ describe('Action Schematic', () => { expect(fileContent).toMatch(/export enum FooActionTypes/); }); + it('should create an type named "FooActions"', () => { + const tree = schematicRunner.runSchematic( + 'action', + defaultOptions, + appTree + ); + const fileContent = tree.readContent( + `${projectPath}/src/app/foo.actions.ts` + ); + + expect(fileContent).toMatch(/export type FooActions = Foo/); + }); + it('should group within an "actions" folder if group is set', () => { const tree = schematicRunner.runSchematic( 'action', From a2d24b407b748d704ad5575f51abcb506f219e77 Mon Sep 17 00:00:00 2001 From: kouMatsumoto Date: Thu, 21 Jun 2018 21:46:36 +0900 Subject: [PATCH 2/3] fix(schematics): change an action class name generated --- .../__name@dasherize__.actions.ts | 4 ++-- modules/schematics/src/action/index.spec.ts | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) 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 7de903388a..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,8 +4,8 @@ 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; } -export type <%= classify(name) %>Actions = <%= classify(name) %>; +export type <%= classify(name) %>Actions = Load<%= classify(name) %>s; diff --git a/modules/schematics/src/action/index.spec.ts b/modules/schematics/src/action/index.spec.ts index f28f938fe6..69341ea21c 100644 --- a/modules/schematics/src/action/index.spec.ts +++ b/modules/schematics/src/action/index.spec.ts @@ -69,7 +69,7 @@ describe('Action Schematic', () => { expect(fileContent).toMatch(/export enum FooActionTypes/); }); - it('should create an type named "FooActions"', () => { + it('should create a class named "LoadFoos"', () => { const tree = schematicRunner.runSchematic( 'action', defaultOptions, @@ -79,7 +79,20 @@ describe('Action Schematic', () => { `${projectPath}/src/app/foo.actions.ts` ); - expect(fileContent).toMatch(/export type FooActions = Foo/); + expect(fileContent).toMatch(/export class LoadFoos implements Action/); + }); + + it('should create a type named "FooActions"', () => { + 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', () => { From af01c75afce80698da99b1d9b89c6bf0e9389c47 Mon Sep 17 00:00:00 2001 From: kouMatsumoto Date: Sat, 23 Jun 2018 08:42:32 +0900 Subject: [PATCH 3/3] test(schematics): revise expectations of spec --- modules/schematics/src/action/index.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/schematics/src/action/index.spec.ts b/modules/schematics/src/action/index.spec.ts index 69341ea21c..fc178c06ca 100644 --- a/modules/schematics/src/action/index.spec.ts +++ b/modules/schematics/src/action/index.spec.ts @@ -69,7 +69,7 @@ describe('Action Schematic', () => { expect(fileContent).toMatch(/export enum FooActionTypes/); }); - it('should create a class named "LoadFoos"', () => { + it('should create a class based on the provided name', () => { const tree = schematicRunner.runSchematic( 'action', defaultOptions, @@ -82,7 +82,7 @@ describe('Action Schematic', () => { expect(fileContent).toMatch(/export class LoadFoos implements Action/); }); - it('should create a type named "FooActions"', () => { + it('should create the union type based on the provided name', () => { const tree = schematicRunner.runSchematic( 'action', defaultOptions,