-
-
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 tests] modernize integration/adapter/find-all-test #5737
Conversation
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.
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; |
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.
we should be able to (or should make ourselves able to) eliminate allRecords
being scoped so broadly.
}); | ||
store = env.store; | ||
}, | ||
hooks.afterEach(function() { |
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.
this afterEach is no longer needed at all
adapter.findAll = () => resolve({}); | ||
|
||
assert.expectAssertion(() => { | ||
run(() => store.findAll('person')); |
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.
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.
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'm not sure what's the best approach here, more info at workmanw/ember-qunit-assert-helpers#18.
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.
@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); | ||
}); |
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.
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(() => { |
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.
we should be able to eliminate this use of run
Thanks for the comments, I'll address them. |
Thanks a bunch for the PR! Can you please rebase it against master, there are some merge conflicts with master right now. |
c9c2d94
to
5012e4d
Compare
No description provided.