Skip to content

Commit

Permalink
Merge pull request #5047 from emberjs/cleanup-stuff
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
stefanpenner authored Jul 2, 2017
2 parents 4f2e2ad + a277a1f commit 371e30e
Show file tree
Hide file tree
Showing 12 changed files with 359 additions and 388 deletions.
69 changes: 34 additions & 35 deletions tests/integration/application-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {module, test} from 'qunit';

import DS from 'ember-data';

var run = Ember.run;
var Application = Ember.Application;
var Controller = Ember.Controller;
var Store = DS.Store;
var Namespace = Ember.Namespace;
const run = Ember.run;
const Application = Ember.Application;
const Controller = Ember.Controller;
const Store = DS.Store;
const Namespace = Ember.Namespace;

var app, App, container;
let app, App, container;

/*
These tests ensure that Ember Data works with Ember.js' application
Expand All @@ -28,7 +28,7 @@ function lookup(thing) {

module("integration/application - Injecting a Custom Store", {
beforeEach() {
run(function() {
run(() => {
app = Application.create({
StoreService: Store.extend({ isCustom: true }),
FooController: Controller.extend(),
Expand All @@ -48,30 +48,29 @@ module("integration/application - Injecting a Custom Store", {
});

test("If a Store property exists on an Ember.Application, it should be instantiated.", function(assert) {
run(function() {
run(() => {
assert.ok(getStore().get('isCustom'), "the custom store was instantiated");
});
});

test("If a store is instantiated, it should be made available to each controller.", function(assert) {
var fooController = lookup('controller:foo');
var isCustom = run(fooController, 'get', 'store.isCustom');
let fooController = lookup('controller:foo');
let isCustom = run(fooController, 'get', 'store.isCustom');
assert.ok(isCustom, "the custom store was injected");
});

test("The JSONAPIAdapter is the default adapter when no custom adapter is provided", function(assert) {
run(function() {
var store = getStore();

var adapter = store.adapterFor('application');
run(() => {
let store = getStore();
let adapter = store.adapterFor('application');

assert.ok(adapter instanceof DS.JSONAPIAdapter, 'default adapter should be the JSONAPIAdapter');
});
});

module("integration/application - Injecting the Default Store", {
beforeEach() {
run(function() {
run(() => {
app = Application.create({
FooController: Controller.extend(),
BazController: {},
Expand All @@ -93,22 +92,22 @@ test("If a Store property exists on an Ember.Application, it should be instantia
});

test("If a store is instantiated, it should be made available to each controller.", function(assert) {
run(function() {
var fooController = lookup('controller:foo');
run(() => {
let fooController = lookup('controller:foo');
assert.ok(fooController.get('store') instanceof DS.Store, "the store was injected");
});
});

test("the DS namespace should be accessible", function(assert) {
run(function() {
run(() => {
assert.ok(Namespace.byName('DS') instanceof Namespace, "the DS namespace is accessible");
});
});

if (Ember.inject && Ember.inject.service) {
module("integration/application - Using the store as a service", {
beforeEach() {
run(function() {
run(() => {
app = Application.create({
DoodleService: Ember.Service.extend({ store: Ember.inject.service() })
});
Expand All @@ -124,8 +123,8 @@ if (Ember.inject && Ember.inject.service) {
});

test("The store can be injected as a service", function(assert) {
run(function() {
var doodleService = lookup('service:doodle');
run(() => {
let doodleService = lookup('service:doodle');
assert.ok(doodleService.get('store') instanceof Store, "the store can be used as a service");
});
});
Expand All @@ -145,14 +144,14 @@ module("integration/application - Attaching initializer", {
});

test("ember-data initializer is run", function(assert) {
var ran = false;
let ran = false;
App.initializer({
name: "after-ember-data",
after: "ember-data",
initialize() { ran = true; }
});

run(function() {
run(() => {
app = App.create();
});

Expand All @@ -161,7 +160,7 @@ test("ember-data initializer is run", function(assert) {

test("ember-data initializer does not register the store service when it was already registered", function(assert) {

var AppStore = Store.extend({
let AppStore = Store.extend({
isCustomStore: true
});

Expand All @@ -173,26 +172,26 @@ test("ember-data initializer does not register the store service when it was alr
}
});

run(function() {
run(() => {
app = App.create();
container = app.__container__;
});

var store = getStore();
let store = getStore();
assert.ok(store && store.get('isCustomStore'), 'ember-data initializer does not overwrite the previous registered service store');

});

testInDebug("store initializer is run (DEPRECATED)", function(assert) {
var ran = false;
let ran = false;
App.initializer({
name: "after-store",
after: 'store',
initialize() { ran = true; }
});

assert.expectDeprecation(function() {
run(function() {
assert.expectDeprecation(() => {
run(() => {
app = App.create();
});
}, /The initializer `store` has been deprecated/)
Expand All @@ -201,15 +200,15 @@ testInDebug("store initializer is run (DEPRECATED)", function(assert) {
});

testInDebug("injectStore initializer is run (DEPRECATED)", function(assert) {
var ran = false;
let ran = false;
App.initializer({
name: "after-store",
after: 'injectStore',
initialize() { ran = true; }
});

assert.expectDeprecation(function() {
run(function() {
assert.expectDeprecation(() => {
run(() => {
app = App.create();
});
}, /The initializer `injectStore` has been deprecated/)
Expand All @@ -218,15 +217,15 @@ testInDebug("injectStore initializer is run (DEPRECATED)", function(assert) {
});

testInDebug("transforms initializer is run (DEPRECATED)", function(assert) {
var ran = false;
let ran = false;
App.initializer({
name: "after-store",
after: 'transforms',
initialize() { ran = true; }
});

assert.expectDeprecation(function() {
run(function() {
assert.expectDeprecation(() => {
run(() => {
app = App.create();
});
}, /The initializer `transforms` has been deprecated/)
Expand Down
19 changes: 9 additions & 10 deletions tests/integration/client-id-generation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import {module, test} from 'qunit';

import DS from 'ember-data';

var get = Ember.get;
var Post, Comment, Misc, env;
var run = Ember.run;
const { get, run } = Ember;
let Post, Comment, Misc, env;

module("integration/client_id_generation - Client-side ID Generation", {
beforeEach() {
Expand Down Expand Up @@ -38,7 +37,7 @@ module("integration/client_id_generation - Client-side ID Generation", {
test("If an adapter implements the `generateIdForRecord` method, the store should be able to assign IDs without saving to the persistence layer.", function(assert) {
assert.expect(6);

var idCount = 1;
let idCount = 1;

env.adapter.generateIdForRecord = function(passedStore, record) {
assert.equal(env.store, passedStore, "store is the first parameter");
Expand All @@ -56,7 +55,7 @@ test("If an adapter implements the `generateIdForRecord` method, the store shoul
}
};

var comment, post;
let comment, post;
run(function() {
comment = env.store.createRecord('comment');
post = env.store.createRecord('post');
Expand All @@ -75,10 +74,10 @@ test("If an adapter implements the `generateIdForRecord` method, the store shoul

test("empty string and undefined ids should coerce to null", function(assert) {
assert.expect(6);
var comment, post;
var idCount = 0;
let comment, post;
let idCount = 0;
let id = 1;
var ids = [undefined, ''];
let ids = [undefined, ''];
env.adapter.generateIdForRecord = function(passedStore, record) {
assert.equal(env.store, passedStore, "store is the first parameter");

Expand All @@ -90,7 +89,7 @@ test("empty string and undefined ids should coerce to null", function(assert) {
return Ember.RSVP.resolve({ data: { id: id++, type: type.modelName } });
};

run(function() {
run(() => {
comment = env.store.createRecord('misc');
post = env.store.createRecord('misc');
});
Expand All @@ -100,7 +99,7 @@ test("empty string and undefined ids should coerce to null", function(assert) {

// Despite client-generated IDs, calling commit() on the store should still
// invoke the adapter's `createRecord` method.
run(function() {
run(() => {
comment.save();
post.save();
});
Expand Down
13 changes: 6 additions & 7 deletions tests/integration/inverse-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import {module, test} from 'qunit';

import DS from 'ember-data';

var env, store, User, Job, ReflexiveModel;
let env, store, User, Job, ReflexiveModel;

var attr = DS.attr;
var belongsTo = DS.belongsTo;
var run = Ember.run;
const { attr, belongsTo } = DS;
const { run } = Ember;

function stringify(string) {
return function() { return string; };
Expand Down Expand Up @@ -109,7 +108,7 @@ testInDebug("Errors out if you define 2 inverses to the same model", function(as
job: belongsTo('job', { async: false })
});

assert.expectAssertion(function() {
assert.expectAssertion(() => {
User.inverseFor('job', store);
}, "You defined the 'job' relationship on user, but you defined the inverse relationships of type job multiple times. Look at https://emberjs.com/guides/models/defining-models/#toc_explicit-inverses for how to explicitly specify inverses");
});
Expand All @@ -129,9 +128,9 @@ test("Caches findInverseFor return value", function(assert) {
testInDebug("Errors out if you do not define an inverse for a reflexive relationship", function(assert) {

//Maybe store is evaluated lazily, so we need this :(
assert.expectWarning(function() {
assert.expectWarning(() => {
var reflexiveModel;
run(function() {
run(() => {
store.push({
data: {
type: 'reflexive-model',
Expand Down
18 changes: 6 additions & 12 deletions tests/integration/lifecycle-hooks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {module, test} from 'qunit';

import DS from 'ember-data';

var Person, env;
var attr = DS.attr;
var resolve = Ember.RSVP.resolve;
var run = Ember.run;
let Person, env;
const { attr } = DS;
const { run } = Ember;
const { resolve } = Ember.RSVP;

module("integration/lifecycle_hooks - Lifecycle Hooks", {
beforeEach() {
Expand All @@ -33,11 +33,8 @@ test("When the adapter acknowledges that a record has been created, a `didCreate
env.adapter.createRecord = function(store, type, snapshot) {
return resolve({ data: { id: 99, type: "person", attributes: { name: "Yehuda Katz" } } });
};
var person;

run(function() {
person = env.store.createRecord('person', { name: "Yehuda Katz" });
});
let person = run(() => env.store.createRecord('person', { name: "Yehuda Katz" }));

person.on('didCreate', function() {
assert.equal(this, person, "this is bound to the record");
Expand All @@ -55,11 +52,8 @@ test("When the adapter acknowledges that a record has been created without a new
env.adapter.createRecord = function(store, type, snapshot) {
return Ember.RSVP.resolve();
};
var person;

run(function() {
person = env.store.createRecord('person', { id: 99, name: "Yehuda Katz" });
});
let person = run(() => env.store.createRecord('person', { id: 99, name: "Yehuda Katz" }));

person.on('didCreate', function() {
assert.equal(this, person, "this is bound to the record");
Expand Down
Loading

0 comments on commit 371e30e

Please sign in to comment.