-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[CHORE]: Modernized store-adapter-test #7634
Conversation
this.owner.register('model:person', Person); | ||
this.owner.register('model:dog', Dog); | ||
this.owner.register('adapter:application', JSONAPIAdapter.extend()); | ||
this.owner.register('serializer:application', JSONAPISerializer.extend()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you find that a beforeEach was too overbearing and it was easier to do it in the specific tests that need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, keeping in the spirit of defining individually per test. What do you think of that design choice, has removing beforeEach made tests on the whole too verbose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When writing tests, it probably is preferred to take common test setup and only repeat yourself once (or a few times if you need to make some modifications for a few tests). In this example, we might be able to reduce a few hundred lines of code!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, I am in complete agreement about minimizing redundant code and making the file much smaller! I was basing this change on: #7567 (review)
Why was it more preferred to eliminate the beforeEach in that PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question. I think it was a bit more nuanced in that example. In that PR, it was re-declaring Post
(via Post = ...
). Effectively taking over Post
from something that had greater scope access. In this case, the thing in the beforeEach here is necessary setup for each test. From looking at the tests briefly, we just may want the most broad test setup. So that looks like a Person with 2 attributes and a relationship....As well as a Dog with one attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, great explanation thank you! I'll roll this back a couple of commits and put the beforeEach back in
1f4edcf
to
185044c
Compare
185044c
to
cdc8a1f
Compare
cdc8a1f
to
a66c300
Compare
No description provided.