Skip to content

Commit

Permalink
CHORE: Modernize integration/ tests and remove run loop calls
Browse files Browse the repository at this point in the history
  • Loading branch information
pliljegr committed Aug 20, 2019
1 parent d75ca0e commit 3119c09
Show file tree
Hide file tree
Showing 9 changed files with 1,153 additions and 1,072 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ module('integration/adapter/find-all - Finding All Records of a Type', function(
);

store.createRecord('person', { name: 'Carsten Nielsen' });
await settled();

await settled();

Expand Down
12 changes: 3 additions & 9 deletions packages/-ember-data/tests/integration/application-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Namespace from '@ember/application/namespace';
import Service, { inject as service } from '@ember/service';
import Controller from '@ember/controller';
import Application from '@ember/application';
import { run } from '@ember/runloop';
import Store from 'ember-data/store';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
Expand Down Expand Up @@ -110,12 +109,6 @@ module('integration/application - Attaching initializer', function(hooks) {
this.owner = null;
});

hooks.afterEach(function() {
if (this.application !== null) {
run(this.application, 'destroy');
}
});

test('ember-data initializer is run', async function(assert) {
let ran = false;

Expand All @@ -129,7 +122,7 @@ module('integration/application - Attaching initializer', function(hooks) {

this.application = this.TestApplication.create({ autoboot: false });

await run(() => this.application.boot());
await this.application.boot();

assert.ok(ran, 'ember-data initializer was found');
});
Expand All @@ -149,7 +142,8 @@ module('integration/application - Attaching initializer', function(hooks) {

this.application = this.TestApplication.create({ autoboot: false });

await run(() => this.application.boot().then(() => (this.owner = this.application.buildInstance())));
await this.application.boot();
this.owner = this.application.buildInstance();

let store = this.owner.lookup('service:store');
assert.ok(
Expand Down
17 changes: 11 additions & 6 deletions packages/-ember-data/tests/integration/debug-adapter-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { setupTest } from 'ember-qunit';
import { A } from '@ember/array';
import { get } from '@ember/object';
import { run } from '@ember/runloop';
import Model from '@ember-data/model';
import Adapter from '@ember-data/adapter';
import { DebugAdapter } from 'ember-data/-private';
import { module, test } from 'qunit';
import { settled } from '@ember/test-helpers';
import { attr } from '@ember-data/model';
Expand All @@ -16,24 +16,25 @@ class Post extends Model {
module('integration/debug-adapter - DS.DebugAdapter', function(hooks) {
setupTest(hooks);

let store, debugAdapter;
let store;

hooks.beforeEach(function() {
let { owner } = this;

owner.register('model:post', Post);
store = owner.lookup('service:store');
debugAdapter = owner.lookup('data-adapter:main');

debugAdapter.reopen({
let _adapter = DebugAdapter.extend({
getModelTypes() {
return A([{ klass: Post, name: 'post' }]);
},
});
owner.register('data-adapter:main', _adapter);
});

test('Watching Model Types', async function(assert) {
assert.expect(5);
let { owner } = this;
let debugAdapter = owner.lookup('data-adapter:main');

function added(types) {
assert.equal(types.length, 1, 'added one type');
Expand All @@ -60,6 +61,8 @@ module('integration/debug-adapter - DS.DebugAdapter', function(hooks) {
});

test('Watching Records', async function(assert) {
let { owner } = this;
let debugAdapter = owner.lookup('data-adapter:main');
let addedRecords, updatedRecords, removedIndex, removedCount;

this.owner.register(
Expand Down Expand Up @@ -156,7 +159,7 @@ module('integration/debug-adapter - DS.DebugAdapter', function(hooks) {
addedRecords = updatedRecords = [];
removedCount = removedIndex = null;

run(() => post.unloadRecord());
post.unloadRecord();

await settled();

Expand All @@ -165,6 +168,8 @@ module('integration/debug-adapter - DS.DebugAdapter', function(hooks) {
});

test('Column names', function(assert) {
let { owner } = this;
let debugAdapter = owner.lookup('data-adapter:main');
class Person extends Model {
@attr()
title;
Expand Down
Loading

0 comments on commit 3119c09

Please sign in to comment.