From a97861c6d129bbd48a0a6fb6baa92dcdd67b3857 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 13 Apr 2015 21:17:41 +0200 Subject: [PATCH] improve unloadType and unloadAll tests --- .../tests/integration/records/unload-test.js | 50 +++++++++++++++---- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/packages/ember-data/tests/integration/records/unload-test.js b/packages/ember-data/tests/integration/records/unload-test.js index 8bbf5544c8e..89969c1cae6 100644 --- a/packages/ember-data/tests/integration/records/unload-test.js +++ b/packages/ember-data/tests/integration/records/unload-test.js @@ -55,10 +55,19 @@ 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() { @@ -66,30 +75,52 @@ test("can unload all records for a given type", function () { }); 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() { @@ -97,6 +128,7 @@ test("can unload all records", function () { }); 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 () {