-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test + fix for chained async has many (#7691)
* [bugfix]: fix for chained async has many * add fix and update tests * remove console.logs * make work with flags off * fix test for lts Co-authored-by: Chris Thoburn <[email protected]>
- Loading branch information
Showing
9 changed files
with
294 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1624,7 +1624,7 @@ module('integration/relationships/one_to_many_test - OneToMany relationships', f | |
assert.strictEqual(account.get('user'), null, 'Account does not have the user anymore'); | ||
}); | ||
|
||
test('createRecord updates inverse record array which has observers', function (assert) { | ||
test('createRecord updates inverse record array which has observers', async function (assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let adapter = store.adapterFor('application'); | ||
|
||
|
@@ -1642,21 +1642,26 @@ module('integration/relationships/one_to_many_test - OneToMany relationships', f | |
}; | ||
}; | ||
|
||
return store.findAll('user').then((users) => { | ||
assert.strictEqual(users.get('length'), 1, 'Exactly 1 user'); | ||
const users = await store.findAll('user'); | ||
assert.strictEqual(users.get('length'), 1, 'Exactly 1 user'); | ||
|
||
let user = users.get('firstObject'); | ||
assert.strictEqual(user.get('messages.length'), 0, 'Record array is initially empty'); | ||
let user = users.get('firstObject'); | ||
assert.strictEqual(user.get('messages.length'), 0, 'Record array is initially empty'); | ||
|
||
// set up an observer | ||
user.addObserver('[email protected]', () => {}); | ||
user.get('messages.firstObject'); | ||
// set up an observer | ||
user.addObserver('[email protected]', () => {}); | ||
user.get('messages.firstObject'); | ||
|
||
let message = store.createRecord('message', { user, title: 'EmberFest was great' }); | ||
assert.strictEqual(user.get('messages.length'), 1, 'The message is added to the record array'); | ||
const messages = await user.messages; | ||
|
||
let messageFromArray = user.get('messages.firstObject'); | ||
assert.ok(message === messageFromArray, 'Only one message record instance should be created'); | ||
}); | ||
assert.strictEqual(messages.length, 0, 'we have no messages'); | ||
assert.strictEqual(user.messages.length, 0, 'we have no messages'); | ||
|
||
let message = store.createRecord('message', { user, title: 'EmberFest was great' }); | ||
assert.strictEqual(messages.length, 1, 'The message is added to the record array'); | ||
assert.strictEqual(user.messages.length, 1, 'The message is added to the record array'); | ||
|
||
let messageFromArray = user.messages.firstObject; | ||
assert.true(message === messageFromArray, 'Only one message record instance should be created'); | ||
}); | ||
}); |
Oops, something went wrong.