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): fixed the schematics/action spec template #2092

Merged
merged 3 commits into from
Sep 8, 2019

Conversation

agugan
Copy link
Contributor

@agugan agugan commented Aug 27, 2019

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

when you use the action schematic to generate an action unit test without creators, you get a failing unit test because of the wrong imports.

Closes #2082

What is the new behavior?

Modified the spec template to properly import the actions and also uses the correct class template inside the test suites

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@ngrxbot
Copy link
Collaborator

ngrxbot commented Aug 27, 2019

Preview docs changes for cdded0d at https://previews.ngrx.io/pr2092-cdded0d/


describe('<%= classify(name) %>', () => {
it('should create an instance', () => {
expect(new <%= classify(name) %>()).toBeTruthy();
expect(new from<%= classify(name)%>.Load<%= classify(name) %>s()).toBeTruthy();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sure. The new test will check for the content generated by the action spec schematics?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, for example

expect(fileContent).toMatch(/export class LoadFoos implements Action/);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the tests Tim. Can you check them ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(new from<%= classify(name)%>.Load<%= classify(name) %>s()).toBeTruthy();
expect(new<%= classify(name)%>Actions.Load<%= classify(name) %>s()).toBeTruthy();

@ngrxbot
Copy link
Collaborator

ngrxbot commented Aug 29, 2019

Preview docs changes for d065a55 at https://previews.ngrx.io/pr2092-d065a55/

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@@ -1,7 +1,7 @@
import { <%= classify(name) %> } from './<%= dasherize(name) %>.actions';
import * as from<%= classify(name) %> from './<%= dasherize(name) %>.actions';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import * as from<%= classify(name) %> from './<%= dasherize(name) %>.actions';
import * as <%= classify(name) %>Actions from './<%= dasherize(name) %>.actions';


describe('<%= classify(name) %>', () => {
it('should create an instance', () => {
expect(new <%= classify(name) %>()).toBeTruthy();
expect(new from<%= classify(name)%>.Load<%= classify(name) %>s()).toBeTruthy();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(new from<%= classify(name)%>.Load<%= classify(name) %>s()).toBeTruthy();
expect(new<%= classify(name)%>Actions.Load<%= classify(name) %>s()).toBeTruthy();

`${projectPath}/src/app/foo.actions.spec.ts`
);

expect(fileContent).toMatch(/expect\(new fromFoo.LoadFoos\(\)\)/);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(fileContent).toMatch(/expect\(new fromFoo.LoadFoos\(\)\)/);
expect(fileContent).toMatch(/expect\(new FooActions.LoadFoos\(\)\)/);

@brandonroberts brandonroberts added the Needs Cleanup Review changes needed label Sep 7, 2019
@ngrxbot
Copy link
Collaborator

ngrxbot commented Sep 8, 2019

Preview docs changes for d6af3ca at https://previews.ngrx.io/pr2092-d6af3ca/

@brandonroberts brandonroberts removed the Needs Cleanup Review changes needed label Sep 8, 2019
@brandonroberts brandonroberts merged commit ed3b1f9 into ngrx:master Sep 8, 2019
@brandonroberts
Copy link
Member

Thanks @agugan!

@agugan agugan deleted the fix/schematics-action-spec branch September 9, 2019 03:18
jordanpowell88 pushed a commit to jordanpowell88/platform that referenced this pull request Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing action unit test without creators from NgRx schematic
4 participants