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

[CHORE]: Modernized store-adapter-test #7634

Merged
merged 11 commits into from
Jul 30, 2022

Conversation

runnerboy22
Copy link
Contributor

No description provided.

@snewcomer snewcomer added 🏷️ chore This PR primarily refactors code or updates dependencies 🎯 canary PR is targeting canary (default) labels Jul 15, 2021
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());
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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!

Copy link
Contributor Author

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?

Copy link
Contributor

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.

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 see, great explanation thank you! I'll roll this back a couple of commits and put the beforeEach back in

@runspired runspired added this to In Development in 🔌 Project Unplug 🔌 via automation Jul 30, 2022
@runspired runspired added this to In Development in 🌲 Project Trim 🌲 via automation Jul 30, 2022
@runspired runspired merged commit a991b6f into emberjs:master Jul 30, 2022
🌲 Project Trim 🌲 automation moved this from In Development to Completed Jul 30, 2022
🔌 Project Unplug 🔌 automation moved this from In Development to Completed Jul 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 canary PR is targeting canary (default) 🏷️ chore This PR primarily refactors code or updates dependencies
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

None yet

3 participants