Skip to content

Commit

Permalink
[CLEANUP] ember watson:methodify tests/
Browse files Browse the repository at this point in the history
Convert to ES6 function declarations in tests.
  • Loading branch information
seanpdoyle committed Nov 13, 2015
1 parent be94da0 commit f4f869c
Show file tree
Hide file tree
Showing 70 changed files with 321 additions and 321 deletions.
4 changes: 2 additions & 2 deletions tests/helpers/ember-assertions/deprecations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const deprecations = {
NONE: 99, // 99 problems and a deprecation ain't one
expecteds: null,
actuals: null,
stubEmber: function() {
stubEmber() {
if (!deprecations.originalEmberDeprecate && Ember.deprecate !== deprecations.originalEmberDeprecate) {
deprecations.originalEmberDeprecate = Ember.deprecate;
}
Expand All @@ -13,7 +13,7 @@ const deprecations = {
deprecations.actuals.push([msg, test]);
};
},
restoreEmber: function() {
restoreEmber() {
Ember.deprecate = deprecations.originalEmberDeprecate;
}
};
Expand Down
10 changes: 5 additions & 5 deletions tests/helpers/ember-assertions/method-call-expectation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ export default function MethodCallExpectation(target, property, testAssert) {
}

MethodCallExpectation.prototype = {
handleCall: function() {
handleCall() {
this.sawCall = true;
return this.originalMethod.apply(this.target, arguments);
},
stubMethod: function(fn) {
stubMethod(fn) {
var context = this;
this.originalMethod = this.target[this.property];
this.target[this.property] = function() {
return context.handleCall.apply(context, arguments);
};
},
restoreMethod: function() {
restoreMethod() {
this.target[this.property] = this.originalMethod;
},
runWithStub: function(fn) {
runWithStub(fn) {
try {
this.stubMethod();
fn();
} finally {
this.restoreMethod();
}
},
assert: function(fn) {
assert(fn) {
this.runWithStub();
this.testAssert.ok(this.sawCall, "Expected "+this.property+" to be called.");
}
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/adapter/build-url-mixin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var passedUrl;
var run = Ember.run;

module("integration/adapter/build-url-mixin - BuildURLMixin with RESTAdapter", {
beforeEach: function() {
beforeEach() {
Post = DS.Model.extend({
name: DS.attr("string")
});
Expand Down Expand Up @@ -156,7 +156,7 @@ test('buildURL - with full URLs in links', function(assert) {

test('buildURL - with camelized names', function(assert) {
adapter.setProperties({
pathForType: function(type) {
pathForType(type) {
var decamelized = Ember.String.decamelize(type);
return Ember.String.underscore(Ember.String.pluralize(decamelized));
}
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/adapter/find-all-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var run = Ember.run;
var env;

module("integration/adapter/find_all - Finding All Records of a Type", {
beforeEach: function() {
beforeEach() {
Person = DS.Model.extend({
updatedAt: DS.attr('string'),
name: DS.attr('string'),
Expand All @@ -28,7 +28,7 @@ module("integration/adapter/find_all - Finding All Records of a Type", {
store = env.store;
},

afterEach: function() {
afterEach() {
run(function() {
if (allRecords) { allRecords.destroy(); }
store.destroy();
Expand All @@ -40,7 +40,7 @@ test("When all records for a type are requested, the store should call the adapt
assert.expect(5);

env.registry.register('adapter:person', DS.Adapter.extend({
findAll: function(store, type, since) {
findAll(store, type, since) {
// this will get called twice
assert.ok(true, "the adapter's findAll method should be invoked");

Expand Down Expand Up @@ -71,7 +71,7 @@ test("When all records for a type are requested, a rejection should reject the p

var count = 0;
env.registry.register('adapter:person', DS.Adapter.extend({
findAll: function(store, type, since) {
findAll(store, type, since) {
// this will get called twice
assert.ok(true, "the adapter's findAll method should be invoked");

Expand Down
12 changes: 6 additions & 6 deletions tests/integration/adapter/find-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var Person, store, env;
var run = Ember.run;

module("integration/adapter/find - Finding Records", {
beforeEach: function() {
beforeEach() {
Person = DS.Model.extend({
updatedAt: DS.attr('string'),
name: DS.attr('string'),
Expand All @@ -23,7 +23,7 @@ module("integration/adapter/find - Finding Records", {
store = env.store;
},

afterEach: function() {
afterEach() {
run(store, 'destroy');
}
});
Expand All @@ -44,7 +44,7 @@ test("When a single record is requested, the adapter's find method should be cal
var count = 0;

env.registry.register('adapter:person', DS.Adapter.extend({
findRecord: function(store, type, id, snapshot) {
findRecord(store, type, id, snapshot) {
assert.equal(type, Person, "the find method is called with the correct type");
assert.equal(count, 0, "the find method is only called once");

Expand All @@ -63,7 +63,7 @@ test("When a single record is requested multiple times, all .find() calls are re
var deferred = Ember.RSVP.defer();

env.registry.register('adapter:person', DS.Adapter.extend({
findRecord: function(store, type, id, snapshot) {
findRecord(store, type, id, snapshot) {
return deferred.promise;
}
}));
Expand Down Expand Up @@ -108,7 +108,7 @@ test("When a single record is requested multiple times, all .find() calls are re

test("When a single record is requested, and the promise is rejected, .find() is rejected.", function(assert) {
env.registry.register('adapter:person', DS.Adapter.extend({
findRecord: function(store, type, id, snapshot) {
findRecord(store, type, id, snapshot) {
return Ember.RSVP.reject();
}
}));
Expand All @@ -124,7 +124,7 @@ test("When a single record is requested, and the promise is rejected, the record
assert.expect(2);

env.registry.register('adapter:person', DS.Adapter.extend({
findRecord: function(store, type, id, snapshot) {
findRecord(store, type, id, snapshot) {
return Ember.RSVP.reject();
}
}));
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/adapter/json-api-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var run = Ember.run;
var User, Post, Comment, Handle, GithubHandle, TwitterHandle, Company, DevelopmentShop, DesignStudio;

module('integration/adapter/json-api-adapter - JSONAPIAdapter', {
beforeEach: function() {
beforeEach() {
User = DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
Expand Down Expand Up @@ -76,7 +76,7 @@ module('integration/adapter/json-api-adapter - JSONAPIAdapter', {
adapter = env.adapter;
},

afterEach: function() {
afterEach() {
run(env.store, 'destroy');
}
});
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/adapter/queries-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var Person, env, store, adapter;
var run = Ember.run;

module("integration/adapter/queries - Queries", {
beforeEach: function() {
beforeEach() {
Person = DS.Model.extend({
updatedAt: DS.attr('string'),
name: DS.attr('string'),
Expand All @@ -23,7 +23,7 @@ module("integration/adapter/queries - Queries", {
adapter = env.adapter;
},

afterEach: function() {
afterEach() {
run(env.container, 'destroy');
}
});
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/adapter/record-persistence-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var all = Ember.RSVP.all;
var hash = Ember.RSVP.hash;

module("integration/adapter/record_persistence - Persisting Records", {
beforeEach: function() {
beforeEach() {
Person = DS.Model.extend({
updatedAt: attr('string'),
name: attr('string'),
Expand All @@ -33,7 +33,7 @@ module("integration/adapter/record_persistence - Persisting Records", {
store = env.store;
},

afterEach: function() {
afterEach() {
run(env.container, 'destroy');
}
});
Expand Down
24 changes: 12 additions & 12 deletions tests/integration/adapter/rest-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var run = Ember.run;
var get = Ember.get;

module("integration/adapter/rest_adapter - REST Adapter", {
beforeEach: function() {
beforeEach() {
Post = DS.Model.extend({
name: DS.attr("string")
});
Expand Down Expand Up @@ -332,7 +332,7 @@ test("create - a serializer's attribute mapping takes precdence over keyForAttri
name: 'given_name'
},

keyForAttribute: function(attr) {
keyForAttribute(attr) {
return attr.toUpperCase();
}
}));
Expand All @@ -354,7 +354,7 @@ test("create - a serializer's attribute mapping takes precedence over keyForRela
post: 'article'
},

keyForRelationship: function(attr, kind) {
keyForRelationship(attr, kind) {
return attr.toUpperCase();
}
}));
Expand All @@ -379,7 +379,7 @@ test("create - a serializer's attribute mapping takes precedence over keyForRela
comments: 'opinions'
},

keyForRelationship: function(attr, kind) {
keyForRelationship(attr, kind) {
return attr.toUpperCase();
}
}));
Expand Down Expand Up @@ -1994,14 +1994,14 @@ test('groupRecordsForFindMany groups records correctly when singular URLs are en

test('normalizeKey - to set up _ids and _id', function(assert) {
env.registry.register('serializer:application', DS.RESTSerializer.extend({
keyForAttribute: function(attr) {
keyForAttribute(attr) {
return Ember.String.underscore(attr);
},

keyForBelongsTo: function(belongsTo) {
keyForBelongsTo(belongsTo) {
},

keyForRelationship: function(rel, kind) {
keyForRelationship(rel, kind) {
if (kind === 'belongsTo') {
var underscored = Ember.String.underscore(rel);
return underscored + '_id';
Expand Down Expand Up @@ -2166,7 +2166,7 @@ test("calls adapter.handleResponse with the jqXHR and json", function(assert) {
var originalAjax = Ember.$.ajax;
var jqXHR = {
status: 200,
getAllResponseHeaders: function() { return ''; }
getAllResponseHeaders() { return ''; }
};
var data = {
post: {
Expand Down Expand Up @@ -2200,7 +2200,7 @@ test('calls handleResponse with jqXHR, jqXHR.responseText', function(assert) {
var jqXHR = {
status: 400,
responseText: 'Nope lol',
getAllResponseHeaders: function() { return ''; }
getAllResponseHeaders() { return ''; }
};

Ember.$.ajax = function(hash) {
Expand Down Expand Up @@ -2228,7 +2228,7 @@ test("rejects promise if DS.AdapterError is returned from adapter.handleResponse
assert.expect(3);
var originalAjax = Ember.$.ajax;
var jqXHR = {
getAllResponseHeaders: function() { return ''; }
getAllResponseHeaders() { return ''; }
};
var data = {
something: 'is invalid'
Expand Down Expand Up @@ -2259,7 +2259,7 @@ test('on error appends errorThrown for sanity', function(assert) {
var originalAjax = Ember.$.ajax;
var jqXHR = {
responseText: 'Nope lol',
getAllResponseHeaders: function() { return ''; }
getAllResponseHeaders() { return ''; }
};

var errorThrown = new Error('nope!');
Expand Down Expand Up @@ -2291,7 +2291,7 @@ test('on error wraps the error string in an DS.AdapterError object', function(as
var originalAjax = Ember.$.ajax;
var jqXHR = {
responseText: '',
getAllResponseHeaders: function() { return ''; }
getAllResponseHeaders() { return ''; }
};

var errorThrown = 'nope!';
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/adapter/serialize-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var run = Ember.run;
var env, store, adapter, serializer;

module("integration/adapter/serialize - DS.Adapter integration test", {
beforeEach: function() {
beforeEach() {
var Person = DS.Model.extend({
name: DS.attr('string')
});
Expand All @@ -20,7 +20,7 @@ module("integration/adapter/serialize - DS.Adapter integration test", {
serializer = store.serializerFor('person');
},

afterEach: function() {
afterEach() {
run(env.container, 'destroy');
}
});
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/adapter/store-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var run = Ember.run;
var Person, Dog, env, store, adapter;

module("integration/adapter/store-adapter - DS.Store and DS.Adapter integration test", {
beforeEach: function() {
beforeEach() {
Person = DS.Model.extend({
updatedAt: DS.attr('string'),
name: DS.attr('string'),
Expand All @@ -41,7 +41,7 @@ module("integration/adapter/store-adapter - DS.Store and DS.Adapter integration
adapter = env.adapter;
},

afterEach: function() {
afterEach() {
run(env.container, 'destroy');
}
});
Expand Down Expand Up @@ -1346,7 +1346,7 @@ test("An async hasMany relationship with links should not trigger shouldBackgrou
post: Post,
comment: Comment,
adapter: DS.RESTAdapter.extend({
findRecord: function() {
findRecord() {
return {
posts: {
id: 1,
Expand All @@ -1355,7 +1355,7 @@ test("An async hasMany relationship with links should not trigger shouldBackgrou
}
};
},
findHasMany: function() {
findHasMany() {
return Ember.RSVP.resolve({
comments: [
{ id: 1, name: "FIRST" },
Expand All @@ -1364,7 +1364,7 @@ test("An async hasMany relationship with links should not trigger shouldBackgrou
]
});
},
shouldBackgroundReloadRecord: function() {
shouldBackgroundReloadRecord() {
assert.ok(false, 'shouldBackgroundReloadRecord should not be called');
}
})
Expand Down
Loading

0 comments on commit f4f869c

Please sign in to comment.