-
-
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.
Rename & deprecate store.all for store.peekAll
- Loading branch information
1 parent
f49a20a
commit 3d4939b
Showing
18 changed files
with
140 additions
and
101 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
var get = Ember.get; | ||
var run = Ember.run; | ||
|
||
var Person, store, array, moreArray; | ||
|
||
module("integration/peek_all - DS.Store#peekAll()", { | ||
setup: function() { | ||
array = [{ id: 1, name: "Scumbag Dale" }, { id: 2, name: "Scumbag Katz" }]; | ||
moreArray = [{ id: 3, name: "Scumbag Bryn" }]; | ||
Person = DS.Model.extend({ name: DS.attr('string') }); | ||
|
||
store = createStore({ person: Person }); | ||
}, | ||
teardown: function() { | ||
run(store, 'destroy'); | ||
Person = null; | ||
array = null; | ||
} | ||
}); | ||
|
||
test("store.peekAll('person') should return all records and should update with new ones", function() { | ||
run(function() { | ||
store.pushMany('person', array); | ||
}); | ||
|
||
var all = store.peekAll('person'); | ||
equal(get(all, 'length'), 2); | ||
|
||
run(function() { | ||
store.pushMany('person', moreArray); | ||
}); | ||
|
||
equal(get(all, 'length'), 3); | ||
}); | ||
|
||
test("Calling store.peekAll() multiple times should update immediately inside the runloop", function() { | ||
expect(3); | ||
|
||
Ember.run(function() { | ||
equal(get(store.peekAll('person'), 'length'), 0, 'should initially be empty'); | ||
store.createRecord('person', { name: "Tomster" }); | ||
equal(get(store.peekAll('person'), 'length'), 1, 'should contain one person'); | ||
store.push('person', { id: 1, name: "Tomster's friend" }); | ||
equal(get(store.peekAll('person'), 'length'), 2, 'should contain two people'); | ||
}); | ||
}); | ||
|
||
test("Calling store.peekAll() after creating a record should return correct data", function() { | ||
expect(1); | ||
|
||
Ember.run(function() { | ||
store.createRecord('person', { name: "Tomster" }); | ||
equal(get(store.peekAll('person'), 'length'), 1, 'should contain one person'); | ||
}); | ||
}); | ||
|
||
test("store.all() is deprecated", function() { | ||
expectDeprecation( | ||
function() { | ||
run(function() { | ||
store.all('person'); | ||
}); | ||
}, | ||
'Using store.all() has been deprecated. Use store.peekAll() to get all records by a given type without triggering a fetch.' | ||
); | ||
}); |
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
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
Oops, something went wrong.