From 6fd0a3dffc11dd4e36de7fb41b5e7e98dec6f272 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Fri, 12 Jul 2019 10:27:08 -0700 Subject: [PATCH] some cleanup --- .../integration/record-array-manager-test.js | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/-ember-data/tests/integration/record-array-manager-test.js b/packages/-ember-data/tests/integration/record-array-manager-test.js index d170cf5aaee..f5c9a1ad35c 100644 --- a/packages/-ember-data/tests/integration/record-array-manager-test.js +++ b/packages/-ember-data/tests/integration/record-array-manager-test.js @@ -1,7 +1,7 @@ import { A } from '@ember/array'; import { setupTest } from 'ember-qunit'; import OrderedSet from '@ember/ordered-set'; - +import { settled } from '@ember/test-helpers'; import { module, test } from 'qunit'; import Model from '@ember-data/model'; @@ -59,9 +59,6 @@ module('integration/record_array_manager', function(hooks) { } test('destroying the store correctly cleans everything up', async function(assert) { - let query = {}; - let person; - store.push({ data: { type: 'car', @@ -78,7 +75,7 @@ module('integration/record_array_manager', function(hooks) { }, }); - store.push({ + let person = store.push({ data: { type: 'person', id: '1', @@ -92,30 +89,36 @@ module('integration/record_array_manager', function(hooks) { }, }, }); - person = store.peekRecord('person', 1); let all = store.peekAll('person'); + let query = {}; let adapterPopulated = manager.createAdapterPopulatedRecordArray('person', query); let allSummary = tap(all, 'willDestroy'); let adapterPopulatedSummary = tap(adapterPopulated, 'willDestroy'); let internalPersonModel = person._internalModel; - assert.equal(allSummary.called.length, 0); - assert.equal(adapterPopulatedSummary.called.length, 0); - assert.equal(internalPersonModel._recordArrays.size, 1, 'expected the person to be a member of 1 recordArrays'); - assert.equal('person' in manager._liveRecordArrays, true); + assert.equal(allSummary.called.length, 0, 'initial: no calls to all.willDestroy'); + assert.equal(adapterPopulatedSummary.called.length, 0, 'initial: no calls to adapterPopulated.willDestroy'); + assert.equal( + internalPersonModel._recordArrays.size, + 1, + 'initial: expected the person to be a member of 1 recordArrays' + ); + assert.equal('person' in manager._liveRecordArrays, true, 'initial: we have a live array for person'); - await all.destroy(); + all.destroy(); + await settled(); assert.equal(internalPersonModel._recordArrays.size, 0, 'expected the person to be a member of 1 recordArrays'); - assert.equal(allSummary.called.length, 1); - assert.equal('person' in manager._liveRecordArrays, false); + assert.equal(allSummary.called.length, 1, 'all.willDestroy called once'); + assert.equal('person' in manager._liveRecordArrays, false, 'no longer have a live array for person'); - await manager.destroy(); + manager.destroy(); + await settled(); assert.equal(internalPersonModel._recordArrays.size, 0, 'expected the person to be a member of no recordArrays'); - assert.equal(allSummary.called.length, 1); - assert.equal(adapterPopulatedSummary.called.length, 1); + assert.equal(allSummary.called.length, 1, 'all.willDestroy still only called once'); + assert.equal(adapterPopulatedSummary.called.length, 1, 'adapterPopulated.willDestroy called once'); }); test('batch liveRecordArray changes', async function(assert) {