Skip to content

Commit

Permalink
improve unloadType and unloadAll tests
Browse files Browse the repository at this point in the history
  • Loading branch information
svox1 committed Apr 13, 2015
1 parent aad7ee1 commit a97861c
Showing 1 changed file with 41 additions and 9 deletions.
50 changes: 41 additions & 9 deletions packages/ember-data/tests/integration/records/unload-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,48 +55,80 @@ test("can unload a single record", function () {
});

test("can unload all records for a given type", function () {
var adam, bob;
expect(2);

var adam, bob, dudu;
run(function() {
adam = env.store.push('person', { id: 1, name: "Adam Sunderland" });
bob = env.store.push('person', { id: 2, name: "Bob Bobson" });

dudu = env.store.push('car', {
id: 1,
make: "VW",
model: "Beetle",
person: 1
});
});

Ember.run(function() {
env.store.unloadType('person');
});

equal(env.store.all('person').get('length'), 0);
equal(env.store.all('car').get('length'), 1);
});

test("Using store#unloadAll('type') is deprecated", function() {
var adam, bob;
expect(3);

var adam, bob, dudu;
run(function() {
adam = env.store.push('person', { id: 1, name: "Adam Sunderland" });
bob = env.store.push('person', { id: 2, name: "Bob Bobson" });

dudu = env.store.push('car', {
id: 1,
make: "VW",
model: "Beetle",
person: 1
});
});

expectDeprecation(
function() {
run(function() {
env.store.unloadAll('car');
});
},
'Using store.unloadAll(type) has been deprecated. You should use store.unloadType(type) instead.'
function() {
run(function() {
env.store.unloadAll('person');
});
},
'Using store.unloadAll(type) has been deprecated. You should use store.unloadType(type) instead.'
);

equal(env.store.all('person').get('length'), 0);
equal(env.store.all('car').get('length'), 1);
});

test("can unload all records", function () {
var adam, bob;
expect(2);

var adam, bob, dudu;
run(function() {
adam = env.store.push('person', { id: 1, name: "Adam Sunderland" });
bob = env.store.push('person', { id: 2, name: "Bob Bobson" });

dudu = env.store.push('car', {
id: 1,
make: "VW",
model: "Beetle",
person: 1
});
});

Ember.run(function() {
env.store.unloadAll();
});

equal(env.store.all('person').get('length'), 0);
equal(env.store.all('car').get('length'), 0);
});

test("Unloading all records for a given type clears saved meta data.", function () {
Expand Down

0 comments on commit a97861c

Please sign in to comment.