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 tests] modernize integration/adapter/find-all-test #5737

Merged
merged 1 commit into from
Nov 20, 2018

Conversation

thorsteinsson
Copy link
Member

No description provided.

Copy link
Contributor

@runspired runspired left a comment

Choose a reason for hiding this comment

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

Thank you very much!

I'd be happy taking this improvement "as is" if you don't have time to follow up on a few smaller cleanup items, but left some notes for some things that could be tidier.


module('integration/adapter/find-all - Finding All Records of a Type', function(hooks) {
setupTest(hooks);
let store, allRecords;
Copy link
Contributor

Choose a reason for hiding this comment

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

we should be able to (or should make ourselves able to) eliminate allRecords being scoped so broadly.

});
store = env.store;
},
hooks.afterEach(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

this afterEach is no longer needed at all

adapter.findAll = () => resolve({});

assert.expectAssertion(() => {
run(() => store.findAll('person'));
Copy link
Contributor

Choose a reason for hiding this comment

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

we can clean this run up in another pass but I believe either expectAssertion itself or a similar util is promise aware that we can use instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what's the best approach here, more info at workmanw/ember-qunit-assert-helpers#18.

Copy link
Contributor

Choose a reason for hiding this comment

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

@thorsteinsson the try .. catch approach is amenable.

return store.findAll('person').then(persons => {
assert.equal(persons.get('isUpdating'), false);
assert.equal(persons.get('length'), 2);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

A better pattern than:

let wait = run(() => return new Promise())
// ... assert intermediate state
await wait;

is

let promise = new Promise()
// ... assert intermediate state
await promise;

mostly this just means you can remove the run here. 👍


return run(() => {
return store.findAll('person').then(persons => {
return run(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should be able to eliminate this use of run

@thorsteinsson
Copy link
Member Author

Thanks for the comments, I'll address them.

@igorT
Copy link
Member

igorT commented Nov 10, 2018

Thanks a bunch for the PR! Can you please rebase it against master, there are some merge conflicts with master right now.

@runspired runspired merged commit 54b3579 into emberjs:master Nov 20, 2018
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.

3 participants