diff --git a/.gitignore b/.gitignore
index 073a871..86fceae 100755
--- a/.gitignore
+++ b/.gitignore
@@ -15,4 +15,3 @@
/libpeerconnection.log
npm-debug.log
testem.log
-*.swp
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
index 08096ef..0cc1c24 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -2,7 +2,8 @@
"predef": [
"document",
"window",
- "-Promise"
+ "-Promise",
+ "require"
],
"browser": true,
"boss": true,
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..0533b91
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,12 @@
+bower_components/
+tests/
+
+.bowerrc
+.editorconfig
+.ember-cli
+.travis.yml
+.npmignore
+**/.gitkeep
+bower.json
+Brocfile.js
+testem.json
diff --git a/README.md b/README.md
index 6590157..4734622 100755
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-[](https://github.com/softlayer/sl-ember-store/releases)  [](LICENSE.md) [](https://www.npmjs.com/package/sl-ember-store)
+[](https://github.com/softlayer/sl-ember-store/releases)  [](LICENSE.md) [](https://www.npmjs.com/package/sl-ember-store)
[](https://david-dm.org/softlayer/sl-ember-store) [](https://david-dm.org/softlayer/sl-ember-store#info=devDependencies)
diff --git a/addon/adapters/ajax.js b/addon/adapters/ajax.js
index 92adfe4..a317789 100755
--- a/addon/adapters/ajax.js
+++ b/addon/adapters/ajax.js
@@ -1,6 +1,7 @@
import Ember from 'ember';
import Adapter from '../adapter';
-module icAjax from 'ic-ajax';
+
+var icAjax = require( 'ic-ajax' );
/**
* @module adapters
diff --git a/bower.json b/bower.json
index 9332ae6..d3dd24c 100755
--- a/bower.json
+++ b/bower.json
@@ -5,13 +5,13 @@
"jquery": "^1.11.1",
"ember": "1.8.1",
"ember-resolver": "~0.1.11",
- "loader.js": "stefanpenner/loader.js#1.0.1",
- "ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3",
- "ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
- "ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2",
- "ember-qunit": "0.1.8",
- "ember-qunit-notifications": "0.0.4",
- "qunit": "~1.15.0",
+ "loader.js": "ember-cli/loader.js#1.0.1",
+ "ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
+ "ember-cli-test-loader": "ember-cli/ember-cli-test-loader#0.1.1",
+ "ember-load-initializers": "ember-cli/ember-load-initializers#0.0.2",
+ "ember-qunit": "0.2.8",
+ "ember-qunit-notifications": "0.0.7",
+ "qunit": "~1.17.1",
"pretender": "0.1.0",
"es5-shim": "^4.0.5"
},
diff --git a/package.json b/package.json
old mode 100755
new mode 100644
index 08da22b..1462056
--- a/package.json
+++ b/package.json
@@ -25,19 +25,22 @@
"broccoli-asset-rev": "^2.0.0",
"broccoli-ember-hbs-template-compiler": "^1.6.1",
"broccoli-static-compiler": "~0.2.1",
+ "broccoli-string-replace": "0.0.2",
"connect-restreamer": "^1.0.1",
- "ember-cli": "0.1.5",
+ "ember-cli": "0.1.15",
+ "ember-cli-app-version": "0.3.1",
+ "ember-cli-babel": "^4.0.0",
"ember-cli-dependency-checker": "0.0.7",
+ "ember-cli-es5-shim": "~0.1.0",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-pretender": "^0.3.1",
- "ember-cli-qunit": "0.1.2",
- "ember-export-application-global": "^1.0.0",
+ "ember-cli-qunit": "0.3.7",
+ "ember-cli-uglify": "1.0.1",
+ "ember-export-application-global": "^1.0.2",
"express": "^4.8.5",
"glob": "^4.0.5",
- "morgan": "^1.5.0",
- "ember-cli-es5-shim": "~0.1.0",
- "broccoli-string-replace": "0.0.2"
+ "morgan": "^1.5.0"
},
"ember-addon": {
"configPath": "tests/dummy/config"
diff --git a/testem.json b/testem.json
index a1f0bfd..a50340c 100644
--- a/testem.json
+++ b/testem.json
@@ -1,6 +1,6 @@
{
"framework": "qunit",
- "test_page": "tests/index.html",
+ "test_page": "tests/index.html?hidepassed",
"launch_in_ci": [
"PhantomJS"
],
diff --git a/tests/.jshintrc b/tests/.jshintrc
index 5a454f0..04c0b4f 100644
--- a/tests/.jshintrc
+++ b/tests/.jshintrc
@@ -6,29 +6,8 @@
"setTimeout",
"$",
"-Promise",
- "QUnit",
"define",
"console",
- "equal",
- "notEqual",
- "notStrictEqual",
- "test",
- "asyncTest",
- "testBoth",
- "testWithDefault",
- "raises",
- "throws",
- "deepEqual",
- "start",
- "stop",
- "ok",
- "strictEqual",
- "module",
- "moduleFor",
- "moduleForComponent",
- "moduleForModel",
- "process",
- "expect",
"visit",
"exists",
"fillIn",
@@ -39,14 +18,15 @@
"findWithAssert",
"wait",
"DS",
- "isolatedContainer",
- "startApp",
"andThen",
"currentURL",
"currentPath",
"currentRouteName",
- "propEqual",
- "sinon"
+ "sinon",
+ "require",
+ "module",
+ "asyncTest",
+ "start"
],
"node": false,
"browser": false,
diff --git a/tests/acceptance/array-of-models-test.js b/tests/acceptance/array-of-models-test.js
index 4a1f01c..6a0722a 100644
--- a/tests/acceptance/array-of-models-test.js
+++ b/tests/acceptance/array-of-models-test.js
@@ -6,21 +6,21 @@ import { test, moduleFor } from 'ember-qunit';
var App;
module('Acceptance: ArrayOfModels', {
- setup: function() {
+ beforeEach: function() {
App = startApp();
},
- teardown: function() {
+ afterEach: function() {
Ember.run(App, 'destroy');
}
});
-test('visiting /arrayOfModels', function() {
+test('visiting /arrayOfModels', function( assert ) {
visit('/demos/arrayOfModels');
andThen(function() {
var arrayModelController = App.__container__.lookup('controller:demos/arrayOfModels');
- equal(currentPath(), 'demos.arrayOfModels');
- ok( arrayModelController.get('model.0') instanceof Foo, 'Controllers model is instance of Foo' );
+ assert.equal(currentPath(), 'demos.arrayOfModels');
+ assert.ok( arrayModelController.get('model.0') instanceof Foo, 'Controllers model is instance of Foo' );
});
});
diff --git a/tests/acceptance/single-model-test.js b/tests/acceptance/single-model-test.js
index 661539e..bef27c5 100644
--- a/tests/acceptance/single-model-test.js
+++ b/tests/acceptance/single-model-test.js
@@ -6,20 +6,20 @@ import { test, moduleFor } from 'ember-qunit';
var App;
module( 'Acceptance: SingleModel', {
- setup: function() {
+ beforeEach: function() {
App = startApp();
},
- teardown: function() {
+ afterEach: function() {
Ember.run(App, 'destroy');
}
});
-test('visiting /singleModel', function() {
+test('visiting /singleModel', function( assert ) {
visit('/demos/singleModel/1');
andThen(function() {
var singleModelController = App.__container__.lookup('controller:demos/singleModel');
- equal(currentPath(), 'demos.singleModel');
- ok( singleModelController.get('model') instanceof Foo, 'Controllers model is instance of Foo' );
+ assert.equal(currentPath(), 'demos.singleModel');
+ assert.ok( singleModelController.get('model') instanceof Foo, 'Controllers model is instance of Foo' );
});
});
diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js
index c59bcd5..be21bdb 100644
--- a/tests/dummy/config/environment.js
+++ b/tests/dummy/config/environment.js
@@ -37,6 +37,9 @@ module.exports = function(environment) {
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
+
+ // Per https://github.com/emberjs/data/pull/1952, this resolves instanceOf checks
+ ENV.APP.MODEL_FACTORY_INJECTIONS = false;
}
if (environment === 'production') {
diff --git a/tests/index.html b/tests/index.html
index ae23d99..ae0cd48 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -14,21 +14,12 @@
{{content-for 'head-footer'}}
diff --git a/tests/test-helper.js b/tests/test-helper.js
index b5f6449..e6cfb70 100644
--- a/tests/test-helper.js
+++ b/tests/test-helper.js
@@ -4,9 +4,3 @@ import {
} from 'ember-qunit';
setResolver(resolver);
-
-document.write('
');
-
-QUnit.config.urlConfig.push({ id: 'nocontainer', label: 'Hide container'});
-var containerVisibility = QUnit.urlParams.nocontainer ? 'hidden' : 'visible';
-document.getElementById('ember-testing-container').style.visibility = containerVisibility;
diff --git a/tests/unit/adapters-test.js b/tests/unit/adapters-test.js
index 3d2b1e6..9f17c3d 100755
--- a/tests/unit/adapters-test.js
+++ b/tests/unit/adapters-test.js
@@ -9,7 +9,7 @@ var adapter,
};
module( 'Unit - sl-ember-store/adapter', {
- setup: function() {
+ beforeEach: function() {
adapter = Adapter.create({
container:{
lookup: function( type ){
@@ -21,26 +21,26 @@ module( 'Unit - sl-ember-store/adapter', {
}
});
},
- teardown: function() {
+ afterEach: function() {
store.runPostQueryHooks.reset();
store.runPreQueryHooks.reset();
}
});
-test( 'runPreQueryHooks should run the prequeryhook once', function() {
+test( 'runPreQueryHooks should run the prequeryhook once', function( assert ) {
adapter.runPreQueryHooks();
- ok( store.runPreQueryHooks.calledOnce );
+ assert.ok( store.runPreQueryHooks.calledOnce );
});
-test( 'runPreQueryHooks should not have run postqueryhook', function() {
+test( 'runPreQueryHooks should not have run postqueryhook', function( assert ) {
adapter.runPreQueryHooks();
- equal( store.runPostQueryHooks.callCount,0 );
+ assert.equal( store.runPostQueryHooks.callCount,0 );
});
-test( 'runPostQueryHooks should run the postqueryhook once', function() {
+test( 'runPostQueryHooks should run the postqueryhook once', function( assert ) {
adapter.runPostQueryHooks();
- ok( store.runPostQueryHooks.calledOnce );
+ assert.ok( store.runPostQueryHooks.calledOnce );
});
-test( 'runPostQueryHooks should not have run the prequeryhook', function() {
+test( 'runPostQueryHooks should not have run the prequeryhook', function( assert ) {
adapter.runPostQueryHooks();
- equal( store.runPreQueryHooks.callCount,0 );
+ assert.equal( store.runPreQueryHooks.callCount,0 );
});
diff --git a/tests/unit/adapters/ajax-test.js b/tests/unit/adapters/ajax-test.js
index 04035db..59a0ef6 100755
--- a/tests/unit/adapters/ajax-test.js
+++ b/tests/unit/adapters/ajax-test.js
@@ -4,7 +4,8 @@ import Model from 'sl-ember-store/model';
import Adapter from 'sl-ember-store/adapter';
import Store from 'sl-ember-store/store';
import AjaxAdapter from 'sl-ember-store/adapters/ajax';
-module icAjax from 'ic-ajax';
+
+var icAjax = require( 'ic-ajax' );
var ajaxAdapter,
Foo = Model.extend(),
@@ -14,7 +15,7 @@ var ajaxAdapter,
requestSpy;
module( 'Unit - sl-ember-store/adapter/ajax', {
- setup: function() {
+ beforeEach: function() {
var container = {
registry: [],
cache: {},
@@ -84,122 +85,122 @@ module( 'Unit - sl-ember-store/adapter/ajax', {
//spies
requestSpy = sinon.spy( icAjax, 'request' );
},
- teardown: function() {
+ afterEach: function() {
icAjax.request.restore();
}
});
-function ajaxTestSuite(){
- ok( requestSpy.calledOnce, 'request called once' );
- ok( response.then, 'response is a promise' );
- ok( Ember.PromiseProxyMixin.detect( response ), 'response is a promise proxy' );
+function ajaxTestSuite( assert ){
+ assert.ok( requestSpy.calledOnce, 'request called once' );
+ assert.ok( response.then, 'response is a promise' );
+ assert.ok( Ember.PromiseProxyMixin.detect( response ), 'response is a promise proxy' );
}
-asyncTest( '__find single model with id', function(){
+asyncTest( '__find single model with id', function( assert ){
- expect(6);
+ assert.expect(6);
response = ajaxAdapter.find( 'foo', 1 );
- equal( requestSpy.args[0][0].url, '/foo', 'should call icAjax.request with the correct arguments');
+ assert.equal( requestSpy.args[0][0].url, '/foo', 'should call icAjax.request with the correct arguments');
- equal( requestSpy.args[0][0].data.id, 1, 'should call icAjax.request with the correct arguments');
+ assert.equal( requestSpy.args[0][0].data.id, 1, 'should call icAjax.request with the correct arguments');
- ajaxTestSuite();
+ ajaxTestSuite( assert );
response.then( function(){
- ok( response.get('content') instanceof Foo, 'response is instance of Foo' );
+ assert.ok( response.get('content') instanceof Foo, 'response is instance of Foo' );
start();
});
});
-asyncTest( '__find single model with no id', function(){
+asyncTest( '__find single model with no id', function( assert ){
var options = {data: {main: true }};
response = ajaxAdapter.find( 'foo', null, options, true );
- equal( requestSpy.args[0][0].url, '/foo', 'should call icAjax.request with the correct arguments');
+ assert.equal( requestSpy.args[0][0].url, '/foo', 'should call icAjax.request with the correct arguments');
- ok( requestSpy.args[0][0].data.main, 'should call icAjax.request with the correct arguments');
+ assert.ok( requestSpy.args[0][0].data.main, 'should call icAjax.request with the correct arguments');
- ajaxTestSuite();
+ ajaxTestSuite( assert );
response.then( function(){
- ok( response.get('content') instanceof Foo, 'response is instance of Foo' );
+ assert.ok( response.get('content') instanceof Foo, 'response is instance of Foo' );
start();
});
});
-asyncTest( '__find array of model', function(){
+asyncTest( '__find array of model', function( assert ){
var options = {data: {main: true }};
//request
response = ajaxAdapter.find( 'bar', null, options, false );
- ajaxTestSuite();
+ ajaxTestSuite( assert );
- ok( response instanceof Ember.ArrayProxy, 'should return an instance of Ember.ArrayProxy' );
+ assert.ok( response instanceof Ember.ArrayProxy, 'should return an instance of Ember.ArrayProxy' );
response.then( function(){
- ok( response.content[0] instanceof Bar, 'should return an array of Bar models' );
- ok( response.content[1] instanceof Bar, 'should return an array of Bar models' );
+ assert.ok( response.content[0] instanceof Bar, 'should return an array of Bar models' );
+ assert.ok( response.content[1] instanceof Bar, 'should return an array of Bar models' );
start();
});
});
-asyncTest( 'find should throw error if request fails', function(){
+asyncTest( 'find should throw error if request fails', function( assert ){
var options = { endpoint: 'fail' },
promise = ajaxAdapter.find( 'foo', null, options, false );
promise.then( function( result ){
- ok( false, 'find did not throw an error!' );
+ assert.ok( false, 'find did not throw an error!' );
start();
},
function( result ){
- equal( result.textStatus, 'error', 'find did throw error' );
+ assert.equal( result.textStatus, 'error', 'find did throw error' );
start();
});
});
-asyncTest( 'find should not throw error if response is empty', function(){
+asyncTest( 'find should not throw error if response is empty', function( assert ){
var options = { endpoint: 'noResults' },
promise = ajaxAdapter.find( 'foo', null, options, false );
promise.then( function( result ){
- ok( true, 'find did not throw an error.' );
+ assert.ok( true, 'find did not throw an error.' );
start();
},
function( result ){
- ok( false, 'find threw an error!' );
+ assert.ok( false, 'find threw an error!' );
start();
});
});
-test( 'save', function(){
+test( 'save', function( assert ){
var foo = Foo.create({ test: 'foo', 'bar': { id: 1, quiz: 'bar' } });
response = ajaxAdapter.save( '/foo', foo );
- ok( requestSpy.calledOnce, 'should call icAjax request once' );
- equal( requestSpy.args[0][0].url, '/foo', 'should call icAjax with correct url');
- equal( requestSpy.args[0][0].type, 'POST', 'should call icAjax with correct method');
- equal( typeof requestSpy.args[0][0].data, 'string', 'icAjax should return a string');
+ assert.ok( requestSpy.calledOnce, 'should call icAjax request once' );
+ assert.equal( requestSpy.args[0][0].url, '/foo', 'should call icAjax with correct url');
+ assert.equal( requestSpy.args[0][0].type, 'POST', 'should call icAjax with correct method');
+ assert.equal( typeof requestSpy.args[0][0].data, 'string', 'icAjax should return a string');
});
-test( 'save, should call $.ajax with the correct arguments', function(){
+test( 'save, should call $.ajax with the correct arguments', function( assert ){
var foo = Foo.create({ test: 'foo', 'bar': { id: 1, quiz: 'bar' } });
response = ajaxAdapter.save( '/foo', foo );
- ok( requestSpy.calledOnce, 'request called once' );
- equal( requestSpy.args[0][0].url, '/foo' );
- equal( requestSpy.args[0][0].type, 'POST' );
- equal( typeof requestSpy.args[0][0].data, 'string' );
- ok( response.then, 'response is a promise' );
+ assert.ok( requestSpy.calledOnce, 'request called once' );
+ assert.equal( requestSpy.args[0][0].url, '/foo' );
+ assert.equal( requestSpy.args[0][0].type, 'POST' );
+ assert.equal( typeof requestSpy.args[0][0].data, 'string' );
+ assert.ok( response.then, 'response is a promise' );
});
-test( 'delete, should call icAjax.request once', function(){
+test( 'delete, should call icAjax.request once', function( assert ){
var foo = Foo.create({ id: 1, test: 'foo', 'bar': { id: 1, quiz: 'bar' } });
response = ajaxAdapter.deleteRecord( '/foo', 1 );
- ok( requestSpy.calledOnce );
- equal( requestSpy.args[0][0].url, '/foo', 'should call icAjax with correct url');
- equal( requestSpy.args[0][0].type, 'DELETE', 'should call icAjax with correct url');
- equal( typeof requestSpy.args[0][0].data, 'string', 'icAjax should return a string');
- ok( response.then, 'response is a proxy' );
+ assert.ok( requestSpy.calledOnce );
+ assert.equal( requestSpy.args[0][0].url, '/foo', 'should call icAjax with correct url');
+ assert.equal( requestSpy.args[0][0].type, 'DELETE', 'should call icAjax with correct url');
+ assert.equal( typeof requestSpy.args[0][0].data, 'string', 'icAjax should return a string');
+ assert.ok( response.then, 'response is a proxy' );
});
diff --git a/tests/unit/adapters/localstorage-test.js b/tests/unit/adapters/localstorage-test.js
index 1dee042..7a1274a 100755
--- a/tests/unit/adapters/localstorage-test.js
+++ b/tests/unit/adapters/localstorage-test.js
@@ -17,7 +17,7 @@ var localstorageadapter,
Bar = Model.extend();
module( 'Unit - sl-ember-store/adapter/localstorage', {
- setup: function() {
+ beforeEach: function() {
localStorage = {
_ns: 'testLSObject',
setItem: function( item, content ){
@@ -75,57 +75,57 @@ module( 'Unit - sl-ember-store/adapter/localstorage', {
saveSpy = sinon.spy( localStorage, 'setItem' );
},
- teardown: function() {
+ afterEach: function() {
localStorage.getItem.restore();
localStorage.setItem.restore();
getLocalStorageSpy.restore();
}
});
-asyncTest( '__find single model with id', function(){
+asyncTest( '__find single model with id', function( assert ){
response = localstorageadapter.find( 'foo', 1, { label: '1' } );
- equal(requestSpy.args[0][0], 'sl-ember-store', 'calls request with correct args' );
- ok( response.then, 'response is a promise' );
- ok( Ember.PromiseProxyMixin.detect( response ), 'response is a promise' );
+ assert.equal(requestSpy.args[0][0], 'sl-ember-store', 'calls request with correct args' );
+ assert.ok( response.then, 'response is a promise' );
+ assert.ok( Ember.PromiseProxyMixin.detect( response ), 'response is a promise' );
response.then(function( result ){
- ok( response.get( 'content' ) instanceof Foo, 'response content is instace of Foo' );
+ assert.ok( response.get( 'content' ) instanceof Foo, 'response content is instace of Foo' );
start();
});
});
-asyncTest( '__find single model with no id', function(){
+asyncTest( '__find single model with no id', function( assert ){
var options = {data: {main: true }};
response = localstorageadapter.find( 'foo', null, options, true );
- equal(requestSpy.args[0][0], 'sl-ember-store', 'calls request with correct args' );
+ assert.equal(requestSpy.args[0][0], 'sl-ember-store', 'calls request with correct args' );
- ok( response.then, 'response is a promise' );
+ assert.ok( response.then, 'response is a promise' );
- ok( Ember.PromiseProxyMixin.detect( response ), 'response is a promise' );
+ assert.ok( Ember.PromiseProxyMixin.detect( response ), 'response is a promise' );
response.then(function(){
- ok( response.get( 'content' ) instanceof Foo, 'response content is instace of Foo' );
+ assert.ok( response.get( 'content' ) instanceof Foo, 'response content is instace of Foo' );
start();
});
});
-asyncTest( '__find array of models', function(){
+asyncTest( '__find array of models', function( assert ){
var options = {data: {main: true }};
response = localstorageadapter.find( 'bar', null, options, false );
- ok( Ember.PromiseProxyMixin.detect( response ), 'response is a promise' );
+ assert.ok( Ember.PromiseProxyMixin.detect( response ), 'response is a promise' );
response.then(function(){
- ok( response.get( 'content.0' ) instanceof Bar, 'response content is instace of Bar' );
- ok( response.get( 'content.1' ) instanceof Bar, 'response content is instace of Bar' );
+ assert.ok( response.get( 'content.0' ) instanceof Bar, 'response content is instace of Bar' );
+ assert.ok( response.get( 'content.1' ) instanceof Bar, 'response content is instace of Bar' );
start();
});
});
-asyncTest( 'save', function(){
+asyncTest( 'save', function( assert ){
var fooContent = { id: 2, test: 'foo', 'bar': { id: 1, quiz: 'bar2' } },
foo = Foo.create( fooContent );
@@ -134,14 +134,14 @@ asyncTest( 'save', function(){
var fooRecords = JSON.parse(localStorage.getItem('sl-ember-store')).foo,
fooRecord = fooRecords.findBy( 'id', 2 );
- ok( response.then, 'response is a promise' );
+ assert.ok( response.then, 'response is a promise' );
- equal( fooRecord.id, 2, 'should have added the record to the mock ls object' );
+ assert.equal( fooRecord.id, 2, 'should have added the record to the mock ls object' );
start();
});
});
-asyncTest( 'delete', function(){
+asyncTest( 'delete', function( assert ){
var fooContent = { id: 2, test: 'foo', 'bar': { id: 1, quiz: 'bar2' } },
foo = Foo.create( fooContent ),
r = localstorageadapter.save( '/foo', foo );
@@ -151,18 +151,18 @@ asyncTest( 'delete', function(){
var response = localstorageadapter.deleteRecord( '/foo', 2 );
response.then( function(){
- ok( response.then, 'response is a promise' );
+ assert.ok( response.then, 'response is a promise' );
var fooRecords = [ JSON.parse(localStorage.getItem('sl-ember-store')).foo ],
fooRecord = fooRecords.findBy( 'id', 2 );
- equal( fooRecord, undefined, 'should have deleted the record to the mock ls object' );
+ assert.equal( fooRecord, undefined, 'should have deleted the record to the mock ls object' );
start();
});
});
});
-asyncTest( 'quota test', function(){
+asyncTest( 'quota test', function( assert ){
var fooContent = { id: 1, test: [] },
foo,
r;
@@ -180,11 +180,11 @@ asyncTest( 'quota test', function(){
r.then(
function( result ){
- ok( false, 'Promise did not get rejected!');
+ assert.ok( false, 'Promise did not get rejected!');
start();
},
function( result ){
- equal( result.textStatus, 'error', 'Promise gets rejected for exceeding quota' );
+ assert.equal( result.textStatus, 'error', 'Promise gets rejected for exceeding quota' );
start();
});
});
diff --git a/tests/unit/cache-test.js b/tests/unit/cache-test.js
index 2afb717..f0c1fc1 100755
--- a/tests/unit/cache-test.js
+++ b/tests/unit/cache-test.js
@@ -9,14 +9,14 @@ var cache,
_getRecordSpy;
module( 'Unit - sl-ember-store/cache', {
- setup: function(){
+ beforeEach: function(){
cache = Cache.create();
fetchByIdSpy = sinon.spy( cache, 'fetchById' );
fetchOneSpy = sinon.spy( cache, 'fetchOne' );
_getManyPromiseSpy = sinon.spy( cache, '_getManyPromise' );
_getRecordSpy = sinon.spy( cache, '_getRecords' );
},
- teardown: function(){
+ afterEach: function(){
fetchByIdSpy.restore();
fetchOneSpy.restore();
_getManyPromiseSpy.restore();
@@ -24,71 +24,71 @@ module( 'Unit - sl-ember-store/cache', {
}
});
-test( 'isCached, id', function(){
+test( 'isCached, id', function( assert ){
cache.isCached( 'test', 1 );
- ok( fetchByIdSpy.calledOnce, 'fetch by id called once' );
- equal( fetchByIdSpy.args[0][1], 1, 'fetch by the right id' );
+ assert.ok( fetchByIdSpy.calledOnce, 'fetch by id called once' );
+ assert.equal( fetchByIdSpy.args[0][1], 1, 'fetch by the right id' );
});
-test( 'isCached, one', function(){
+test( 'isCached, one', function( assert ){
cache.isCached( 'test', null, true );
- ok( fetchOneSpy.calledOnce, 'fetch one called once' );
- equal( fetchOneSpy.args[0][0], 'test', 'fetch one called with correct type' );
+ assert.ok( fetchOneSpy.calledOnce, 'fetch one called once' );
+ assert.equal( fetchOneSpy.args[0][0], 'test', 'fetch one called with correct type' );
});
-test( 'isCached, all', function(){
+test( 'isCached, all', function( assert ){
cache.isCached( 'test' );
- ok( _getManyPromiseSpy.calledOnce, 'get all called once');
- equal( _getManyPromiseSpy.args[0][0], 'test', 'get all called with correct type' );
- ok( _getRecordSpy.calledOnce, 'get all called once');
- equal( _getRecordSpy.args[0][0], 'test', 'get all called with correct type' );
+ assert.ok( _getManyPromiseSpy.calledOnce, 'get all called once');
+ assert.equal( _getManyPromiseSpy.args[0][0], 'test', 'get all called with correct type' );
+ assert.ok( _getRecordSpy.calledOnce, 'get all called once');
+ assert.equal( _getRecordSpy.args[0][0], 'test', 'get all called with correct type' );
});
-test( 'clearCache', function(){
+test( 'clearCache', function( assert ){
sinon.spy( cache, '_initializeRecords' );
sinon.spy( cache, '_initializePromises' );
cache.clearCache( 'test' );
- ok( cache._initializeRecords.calledOnce, 'initialize records called once');
- ok( cache._initializeRecords.calledWith( 'test' ), 'initialize records called with correct arg' );
- ok( cache._initializePromises.calledOnce, 'initialize promises called once');
- ok( cache._initializePromises.calledWith( 'test' ), 'initialize records called with correct arg' );
+ assert.ok( cache._initializeRecords.calledOnce, 'initialize records called once');
+ assert.ok( cache._initializeRecords.calledWith( 'test' ), 'initialize records called with correct arg' );
+ assert.ok( cache._initializePromises.calledOnce, 'initialize promises called once');
+ assert.ok( cache._initializePromises.calledWith( 'test' ), 'initialize records called with correct arg' );
});
-test( 'removeRecord', function(){
+test( 'removeRecord', function( assert ){
cache.removeRecord( 'test', Ember.Object.create() );
- ok( cache._getRecords.calledOnce, '_getRecords called once' );
- ok( cache._getRecords.calledWith( 'test' ), '_getRecords called with correct arg');
+ assert.ok( cache._getRecords.calledOnce, '_getRecords called once' );
+ assert.ok( cache._getRecords.calledWith( 'test' ), '_getRecords called with correct arg');
});
-test( 'removeRecords', function(){
+test( 'removeRecords', function( assert ){
sinon.spy( cache, 'removeRecord' );
cache.removeRecords( 'test', [ Ember.Object.create() ] );
- ok( cache.removeRecord.calledOnce, 'removeRecord called once' );
- ok( cache.removeRecord.calledWith( 'test' ), 'removeRecord called with correct arg' );
+ assert.ok( cache.removeRecord.calledOnce, 'removeRecord called once' );
+ assert.ok( cache.removeRecord.calledWith( 'test' ), 'removeRecord called with correct arg' );
});
-test( 'addToCache, single promise', function(){
+test( 'addToCache, single promise', function( assert ){
var result = new Ember.RSVP.Promise(function( resolve ){ resolve( Ember.Object.create() ); });
sinon.spy( cache, 'addPromise');
cache.addToCache( 'test', 1, false, result );
- ok( cache.addPromise.calledOnce, 'addPromise called once' );
- ok( cache.addPromise.calledWith( 'test' ), 'addPromise called with correct args' );
+ assert.ok( cache.addPromise.calledOnce, 'addPromise called once' );
+ assert.ok( cache.addPromise.calledWith( 'test' ), 'addPromise called with correct args' );
});
-test( 'addToCache, all promise', function(){
+test( 'addToCache, all promise', function( assert ){
var result = new Ember.RSVP.Promise(function( resolve ){ resolve( [ Ember.Object.create() ] ); });
sinon.spy( cache, 'addManyPromise');
cache.addToCache( 'test', false, false, result );
- ok( cache.addManyPromise.calledOnce, 'addManyPromise called once' );
- ok( cache.addManyPromise.calledWith( 'test' ), 'addManyPromise called with correct args' );
+ assert.ok( cache.addManyPromise.calledOnce, 'addManyPromise called once' );
+ assert.ok( cache.addManyPromise.calledWith( 'test' ), 'addManyPromise called with correct args' );
});
-test( 'addToCache, record', function(){
+test( 'addToCache, record', function( assert ){
sinon.spy( cache, 'addRecord');
cache.addToCache( 'test', 1, false, Ember.Object.create() );
- ok( cache.addRecord.calledOnce, 'addRecord called once' );
- ok( cache.addRecord.calledWith( 'test' ), 'addRecord called with correct args' );
+ assert.ok( cache.addRecord.calledOnce, 'addRecord called once' );
+ assert.ok( cache.addRecord.calledWith( 'test' ), 'addRecord called with correct args' );
});
-asyncTest( 'addPromise, resolve', function(){
+asyncTest( 'addPromise, resolve', function( assert ){
var testRecord = Ember.Object.create({ id: 1, test: 'test' }),
testPromise = new Ember.RSVP.Promise( function( resolve ){
setTimeout( resolve( testRecord ), 1000);
@@ -98,19 +98,19 @@ asyncTest( 'addPromise, resolve', function(){
sinon.spy( cache, '_getPromises' );
rPromise = cache.addPromise( 'test', 1, testPromise );
- ok( cache._getPromises.calledOnce, '_getPromises called once' );
- equal( cache.get( '_promises.test.ids.1' ), testPromise, 'promise got added to promise cache' );
+ assert.ok( cache._getPromises.calledOnce, '_getPromises called once' );
+ assert.equal( cache.get( '_promises.test.ids.1' ), testPromise, 'promise got added to promise cache' );
//test that promise gets removed from promise hash on resolution
rPromise.finally( function(){
- equal( cache.get( '_promises.test.ids.1' ), undefined, 'promise was removed from cache' );
- ok( cache._getRecords.calledOnce, '_getRecords called once' );
- equal( cache.get( '_records.test.ids.1' ), testRecord, 'record was added to record cache' );
+ assert.equal( cache.get( '_promises.test.ids.1' ), undefined, 'promise was removed from cache' );
+ assert.ok( cache._getRecords.calledOnce, '_getRecords called once' );
+ assert.equal( cache.get( '_records.test.ids.1' ), testRecord, 'record was added to record cache' );
start();
});
});
-asyncTest( 'addPromise, reject', function(){
+asyncTest( 'addPromise, reject', function( assert ){
var testRecord = Ember.Object.create({ id: 1, test: 'test' }),
testPromise = new Ember.RSVP.Promise( function( resolve, reject ){
setTimeout( reject( testRecord ), 1000);
@@ -120,21 +120,21 @@ asyncTest( 'addPromise, reject', function(){
sinon.spy( cache, '_getPromises' );
rPromise = cache.addPromise( 'test', 1, testPromise );
- ok( cache._getPromises.calledOnce, '_getPromises called once' );
- equal( cache.get( '_promises.test.ids.1' ), testPromise, 'promise got added to promise cache' );
+ assert.ok( cache._getPromises.calledOnce, '_getPromises called once' );
+ assert.equal( cache.get( '_promises.test.ids.1' ), testPromise, 'promise got added to promise cache' );
//test that promise gets removed from promise hash on resolution
rPromise.finally( function(){
- equal( cache.get( '_promises.test.ids.1' ), undefined, 'promise was removed from cache' );
- ok( !cache._getRecords.called, '_getRecords not called' );
- equal( cache.get( '_records.test.ids.1' ), undefined, 'record was not added to record cache' );
+ assert.equal( cache.get( '_promises.test.ids.1' ), undefined, 'promise was removed from cache' );
+ assert.ok( !cache._getRecords.called, '_getRecords not called' );
+ assert.equal( cache.get( '_records.test.ids.1' ), undefined, 'record was not added to record cache' );
start();
});
});
-asyncTest( 'addManyPromise, resolve', function(){
+asyncTest( 'addManyPromise, resolve', function( assert ){
var testRecord = Ember.Object.create({ id: 1, test: 'test' }),
testPromise = new Ember.RSVP.Promise( function( resolve ){
setTimeout( resolve( [ testRecord ] ), 100);
@@ -145,17 +145,17 @@ asyncTest( 'addManyPromise, resolve', function(){
sinon.spy( cache, 'addRecords' );
rPromise = cache.addManyPromise( 'test', testPromise );
- ok( cache._getPromises.called >= 1, '_getPromises called at least once' );
- equal( cache.get( '_promises.test.many.firstObject' ), testPromise, 'promise was added to promise cache' );
+ assert.ok( cache._getPromises.called >= 1, '_getPromises called at least once' );
+ assert.equal( cache.get( '_promises.test.many.firstObject' ), testPromise, 'promise was added to promise cache' );
rPromise.then( function(){
- equal( cache.get( '_promises.test.many.length' ), 0, 'promise was removed from promise cache' );
- ok( cache.addRecords.calledOnce, 'addrecords called once' );
- equal( cache.get( '_records.test.ids.1'), testRecord, 'record was added to record cache' );
+ assert.equal( cache.get( '_promises.test.many.length' ), 0, 'promise was removed from promise cache' );
+ assert.ok( cache.addRecords.calledOnce, 'addrecords called once' );
+ assert.equal( cache.get( '_records.test.ids.1'), testRecord, 'record was added to record cache' );
start();
});
});
-asyncTest( 'addManyPromise, reject', function(){
+asyncTest( 'addManyPromise, reject', function( assert ){
var testRecord = Ember.Object.create({ id: 1, test: 'test' }),
testPromise = new Ember.RSVP.Promise( function( resolve, reject ){
setTimeout( reject( [ testRecord ] ), 100);
@@ -166,17 +166,17 @@ asyncTest( 'addManyPromise, reject', function(){
sinon.spy( cache, 'addRecords' );
rPromise = cache.addManyPromise( 'test', testPromise );
- ok( cache._getPromises.called >= 1, '_getPromises called at least once' );
- equal( cache.get( '_promises.test.many.firstObject' ), testPromise, 'promise was added to promise cache' );
+ assert.ok( cache._getPromises.called >= 1, '_getPromises called at least once' );
+ assert.equal( cache.get( '_promises.test.many.firstObject' ), testPromise, 'promise was added to promise cache' );
rPromise.finally( function(){
- equal( cache.get( '_promises.test.many.length' ), 0, 'promise was removed from promise cache' );
- ok( !cache.addRecords.calledOnce, 'addrecords not called once' );
- equal( cache.get( '_records.test.ids.1'), undefined, 'record was added to record cache' );
+ assert.equal( cache.get( '_promises.test.many.length' ), 0, 'promise was removed from promise cache' );
+ assert.ok( !cache.addRecords.calledOnce, 'addrecords not called once' );
+ assert.equal( cache.get( '_records.test.ids.1'), undefined, 'record was added to record cache' );
start();
});
});
-test( 'addRecord', function(){
+test( 'addRecord', function( assert ){
var testRecord = Ember.Object.create({ id: 1, test: 'test' });
var testRecord2 = Ember.Object.create({ id: 1, test: 'test2' });
@@ -184,18 +184,18 @@ test( 'addRecord', function(){
cache.addRecord( 'test', testRecord );
- equal( cache.get( '_records.test.ids.1' ), testRecord, 'testRecord added to record cache' );
+ assert.equal( cache.get( '_records.test.ids.1' ), testRecord, 'testRecord added to record cache' );
- ok( ! cache.removeRecord.called, 'removeRecord was not called on initial add');
+ assert.ok( ! cache.removeRecord.called, 'removeRecord was not called on initial add');
cache.addRecord( 'test', testRecord2 );
- ok( cache.removeRecord.called, 'removeRecord was called on 2nd add');
+ assert.ok( cache.removeRecord.called, 'removeRecord was called on 2nd add');
- equal( cache.get( '_records.test.ids.1' ), testRecord2, 'testRecord2 replaced old record in cache' );
+ assert.equal( cache.get( '_records.test.ids.1' ), testRecord2, 'testRecord2 replaced old record in cache' );
});
-test( 'addRecords', function(){
+test( 'addRecords', function( assert ){
var testRecord = Ember.Object.create({ id: 1, test: 'test' });
var testRecord2 = Ember.Object.create({ id: 2, test: 'test2' });
@@ -203,30 +203,30 @@ test( 'addRecords', function(){
cache.addRecords( 'test', [ testRecord, testRecord2 ] );
- equal( cache.addRecord.callCount, 2, 'addRecord called for each record' );
+ assert.equal( cache.addRecord.callCount, 2, 'addRecord called for each record' );
});
-test( 'fetch, id', function(){
+test( 'fetch, id', function( assert ){
cache.fetch( 'test', 1 );
- ok( fetchByIdSpy.calledOnce, 'fetch by id called once' );
- equal( fetchByIdSpy.args[0][1], 1, 'fetch by the right id' );
+ assert.ok( fetchByIdSpy.calledOnce, 'fetch by id called once' );
+ assert.equal( fetchByIdSpy.args[0][1], 1, 'fetch by the right id' );
});
-test( 'fetch, one', function(){
+test( 'fetch, one', function( assert ){
cache.fetch( 'test', null, true );
- ok( fetchOneSpy.calledOnce, 'fetch one called once' );
- equal( fetchOneSpy.args[0][0], 'test', 'fetch one called with correct type' );
+ assert.ok( fetchOneSpy.calledOnce, 'fetch one called once' );
+ assert.equal( fetchOneSpy.args[0][0], 'test', 'fetch one called with correct type' );
});
-test( 'fetch, all', function(){
+test( 'fetch, all', function( assert ){
cache.fetch( 'test' );
- ok( _getManyPromiseSpy.calledOnce, 'get all called once');
- equal( _getManyPromiseSpy.args[0][0], 'test', 'get all called with correct type' );
- ok( _getRecordSpy.calledOnce, 'get all called once');
- equal( _getRecordSpy.args[0][0], 'test', 'get all called with correct type' );
+ assert.ok( _getManyPromiseSpy.calledOnce, 'get all called once');
+ assert.equal( _getManyPromiseSpy.args[0][0], 'test', 'get all called with correct type' );
+ assert.ok( _getRecordSpy.calledOnce, 'get all called once');
+ assert.equal( _getRecordSpy.args[0][0], 'test', 'get all called with correct type' );
});
-asyncTest( 'fetchOne - promise', function(){
+asyncTest( 'fetchOne - promise', function( assert ){
var testRecord = Ember.Object.create({ id: 1});
cache.addPromise( 'test', 1, Ember.RSVP.Promise.resolve( testRecord ) )
@@ -236,10 +236,10 @@ asyncTest( 'fetchOne - promise', function(){
var response = cache.fetchOne( 'test' );
- ok( cache._getPromises.calledOnce, 'getPromise called once' );
+ assert.ok( cache._getPromises.calledOnce, 'getPromise called once' );
response.then( function(){
- equal( response.get('content'), testRecord, 'fetchOne returned correct record' );
+ assert.equal( response.get('content'), testRecord, 'fetchOne returned correct record' );
start();
});
@@ -247,23 +247,23 @@ asyncTest( 'fetchOne - promise', function(){
});
-asyncTest( 'fetchOne - record', function(){
+asyncTest( 'fetchOne - record', function( assert ){
var testRecord = Ember.Object.create({ id: 1});
cache.addRecord( 'test', testRecord );
var response = cache.fetchOne( 'test' );
- ok( cache._getRecords.called, 'getRecords called once' );
+ assert.ok( cache._getRecords.called, 'getRecords called once' );
response.then( function(){
- equal( response.get('content'), testRecord, 'fetchOne returned the correct record' );
+ assert.equal( response.get('content'), testRecord, 'fetchOne returned the correct record' );
start();
});
});
-asyncTest( 'fetchById - promise', function(){
+asyncTest( 'fetchById - promise', function( assert ){
var testRecord = Ember.Object.create({ id: 1});
cache.addPromise( 'test', 1, Ember.RSVP.Promise.resolve( testRecord ) )
@@ -273,10 +273,10 @@ asyncTest( 'fetchById - promise', function(){
var response = cache.fetchById( 'test', 1 );
- ok( cache._getPromiseById.calledOnce, 'getPromiseById called once' );
+ assert.ok( cache._getPromiseById.calledOnce, 'getPromiseById called once' );
response.then( function(){
- equal( response.get('content'), testRecord, 'fetchById returned correct record' );
+ assert.equal( response.get('content'), testRecord, 'fetchById returned correct record' );
start();
});
@@ -284,7 +284,7 @@ asyncTest( 'fetchById - promise', function(){
});
-asyncTest( 'fetchById - record', function(){
+asyncTest( 'fetchById - record', function( assert ){
var testRecord = Ember.Object.create({ id: 1});
cache.addRecord( 'test', testRecord );
@@ -293,123 +293,123 @@ asyncTest( 'fetchById - record', function(){
var response = cache.fetchById( 'test', 1 );
- ok( cache._getRecordById.calledOnce, 'getRecordById called once' );
+ assert.ok( cache._getRecordById.calledOnce, 'getRecordById called once' );
response.then( function(){
- equal( response.get('content'), testRecord, 'fetchById returned correct record' );
+ assert.equal( response.get('content'), testRecord, 'fetchById returned correct record' );
start();
});
});
-test( 'fetchMany - promise', function(){
+test( 'fetchMany - promise', function( assert ){
var testRecord = Ember.Object.create({ id: 1});
var testPromise = Ember.RSVP.Promise.resolve( [ testRecord] );
cache.addManyPromise( 'test', testPromise);
var response = cache.fetchMany( 'test' );
- ok( cache._getManyPromise.calledOnce, 'calls _getManyPromise once' );
- ok( response, testPromise, 'returns the test promise' );
+ assert.ok( cache._getManyPromise.calledOnce, 'calls _getManyPromise once' );
+ assert.ok( response, testPromise, 'returns the test promise' );
});
-asyncTest( 'fetchMany - record', function(){
+asyncTest( 'fetchMany - record', function( assert ){
var testRecord = Ember.Object.create({ id: 1});
cache.addRecords( 'test', [ testRecord ] );
var response = cache.fetchMany( 'test' );
- ok( cache._getRecords.called, 'calls _getManyRecordsCached once' );
+ assert.ok( cache._getRecords.called, 'calls _getManyRecordsCached once' );
response.then( function(){
- equal( response.get( 'content.0' ), testRecord, 'returns the test record in an array' );
+ assert.equal( response.get( 'content.0' ), testRecord, 'returns the test record in an array' );
start();
});
});
-test( '_setupCache', function(){
+test( '_setupCache', function( assert ){
cache._setupCache();
- equal( Object.keys( cache._records ).length, 0, 'records object is empty' );
- equal( Object.keys( cache._promises ).length, 0, 'promises object is empty' );
+ assert.equal( Object.keys( cache._records ).length, 0, 'records object is empty' );
+ assert.equal( Object.keys( cache._promises ).length, 0, 'promises object is empty' );
});
-test( '_initializeRecords', function(){
+test( '_initializeRecords', function( assert ){
cache._initializeRecords( 'test' );
- equal( cache._records.test.records.length, 0, 'sets up `test` records array' );
- ok( cache._records.test.ids instanceof Ember.Object, 'sets up `test` records object' );
+ assert.equal( cache._records.test.records.length, 0, 'sets up `test` records array' );
+ assert.ok( cache._records.test.ids instanceof Ember.Object, 'sets up `test` records object' );
});
-test( '_getRecords, none', function(){
+test( '_getRecords, none', function( assert ){
var response = cache._getRecords( 'test' );
- equal( response.records.length, 0, 'returns 0 records');
+ assert.equal( response.records.length, 0, 'returns 0 records');
});
-test( '_getRecords, some', function(){
+test( '_getRecords, some', function( assert ){
cache.addRecord( 'test', Ember.Object.create({id:1}));
var response = cache._getRecords( 'test' );
- equal( response.records[0].id, 1, 'returns an array with the test record' );
+ assert.equal( response.records[0].id, 1, 'returns an array with the test record' );
});
-test( '_getRecordById, not found', function(){
+test( '_getRecordById, not found', function( assert ){
var response = cache._getRecordById( 'test', 12 );
- equal( response, undefined, 'record should not be found');
+ assert.equal( response, undefined, 'record should not be found');
});
-test( '_getRecordById, found', function(){
+test( '_getRecordById, found', function( assert ){
var testRecord = Ember.Object.create({id:1});
cache.addRecord( 'test', testRecord);
var response = cache._getRecordById( 'test', 1 );
- equal( response, testRecord, 'returns the correct record' );
+ assert.equal( response, testRecord, 'returns the correct record' );
});
-test( '_getRecords, empty', function(){
+test( '_getRecords, empty', function( assert ){
var response = cache._getRecords( 'test' ).records;
- equal( response.length, 0, 'returns an empty array' );
+ assert.equal( response.length, 0, 'returns an empty array' );
});
-test( '_getRecords, some', function(){
+test( '_getRecords, some', function( assert ){
var testRecord = Ember.Object.create({id:1});
cache.addRecord( 'test', testRecord);
var response = cache._getRecords( 'test' ).records;
- equal( response[0], testRecord, 'returns the test record in an array' );
+ assert.equal( response[0], testRecord, 'returns the test record in an array' );
});
-test( '_initializePromises', function(){
+test( '_initializePromises', function( assert ){
cache._initializePromises( 'test' );
- equal( cache._promises.test.many.firstObject, null, 'test all promise is null ');
- equal( Object.keys(cache._promises.test.ids).length, 0, 'test promise object is empty' );
+ assert.equal( cache._promises.test.many.firstObject, null, 'test all promise is null ');
+ assert.equal( Object.keys(cache._promises.test.ids).length, 0, 'test promise object is empty' );
});
-test( '_getPromises, empty', function(){
+test( '_getPromises, empty', function( assert ){
sinon.spy( cache, '_initializePromises' );
var response = cache._getPromises('test');
- ok( cache._initializePromises.calledOnce, 'calls initializePromises' );
+ assert.ok( cache._initializePromises.calledOnce, 'calls initializePromises' );
});
-test( '_getPromises, some', function(){
+test( '_getPromises, some', function( assert ){
var testPromise = Ember.RSVP.Promise.resolve( Ember.Object.create({id:1}) );
cache.addPromise( 'test', 1, testPromise );
var response = cache._getPromises( 'test' );
- equal( response.ids[1], testPromise, 'has testpromise set' );
+ assert.equal( response.ids[1], testPromise, 'has testpromise set' );
});
-test( '_getPromiseById, none', function(){
+test( '_getPromiseById, none', function( assert ){
var response = cache._getPromiseById( 'test', 1 );
- equal( response, undefined, 'no promise should be found' );
+ assert.equal( response, undefined, 'no promise should be found' );
});
-test( '_getPromiseById, some', function(){
+test( '_getPromiseById, some', function( assert ){
var testPromise = Ember.RSVP.Promise.resolve( Ember.Object.create({id:1}));
cache.addPromise( 'test', 1, testPromise );
var response = cache._getPromiseById( 'test', 1 );
- equal( response, testPromise, 'promise should be found' );
+ assert.equal( response, testPromise, 'promise should be found' );
});
-test( '_getManyPromise, none', function(){
+test( '_getManyPromise, none', function( assert ){
var response = cache._getManyPromise( 'test' );
- equal( response, undefined, 'response should be undefined' );
+ assert.equal( response, undefined, 'response should be undefined' );
});
-asyncTest( '_getManyPromise, some', function(){
+asyncTest( '_getManyPromise, some', function( assert ){
var testRecord = Ember.Object.create({id:1}),
testPromise = Ember.RSVP.Promise.resolve( [ testRecord ] );
@@ -418,12 +418,12 @@ asyncTest( '_getManyPromise, some', function(){
var response = cache._getManyPromise( 'test' );
response.then( function( records ){
- equal( testRecord, records[0], 'should return promise' );
+ assert.equal( testRecord, records[0], 'should return promise' );
start();
});
});
-asyncTest( '_getManyPromise, more', function(){
+asyncTest( '_getManyPromise, more', function( assert ){
var testRecord = Ember.Object.create({id:1}),
testRecord2 = Ember.Object.create({id:2}),
testPromise = Ember.RSVP.Promise.resolve( [ testRecord ] ),
@@ -435,8 +435,8 @@ asyncTest( '_getManyPromise, more', function(){
var response = cache._getManyPromise( 'test' );
response.then( function( records ){
- equal( testRecord, records[0], 'first record should be testRecord' );
- equal( testRecord2, records[1], 'first record should be testRecord' );
+ assert.equal( testRecord, records[0], 'first record should be testRecord' );
+ assert.equal( testRecord2, records[1], 'first record should be testRecord' );
start();
});
});
\ No newline at end of file
diff --git a/tests/unit/initializers/sl-ember-model-test.js b/tests/unit/initializers/sl-ember-model-test.js
index c0eea54..16cdad1 100755
--- a/tests/unit/initializers/sl-ember-model-test.js
+++ b/tests/unit/initializers/sl-ember-model-test.js
@@ -9,49 +9,49 @@ var App,
container;
module( 'Unit - initializer: sl-ember-store', {
- setup: function() {
+ beforeEach: function() {
App = startApp();
container = App.__container__;
},
- teardown: function() {
+ afterEach: function() {
Ember.run( App, App.destroy );
}
});
-test( 'LocalStorage adapter gets namespace set', function(){
+test( 'LocalStorage adapter gets namespace set', function( assert ){
var lsAdapter = container.lookupFactory( 'adapter:localstorage' );
- equal( lsAdapter.namespace, container.lookup( 'application:main' ).get( 'modulePrefix' ) );
+ assert.equal( lsAdapter.namespace, container.lookup( 'application:main' ).get( 'modulePrefix' ) );
});
-test( 'store:main gets registered', function(){
+test( 'store:main gets registered', function( assert ){
var store = container.lookupFactory( 'store:main' );
- ok( Store.detect( store ) );
+ assert.ok( Store.detect( store ) );
});
-test( 'adapter:ajax gets registered', function(){
+test( 'adapter:ajax gets registered', function( assert ){
var ajaxAdapter = container.lookupFactory( 'adapter:ajax' );
- ok( AjaxAdapter.detect( ajaxAdapter ) );
+ assert.ok( AjaxAdapter.detect( ajaxAdapter ) );
});
-test( 'adapter:localstorage gets registered', function(){
+test( 'adapter:localstorage gets registered', function( assert ){
var lsAdapter = container.lookupFactory( 'adapter:localstorage' );
- ok( LocalstorageAdapter.detect( lsAdapter ) );
+ assert.ok( LocalstorageAdapter.detect( lsAdapter ) );
});
-test( 'store gets injected into controllers, routes, adapters', function(){
+test( 'store gets injected into controllers, routes, adapters', function( assert ){
var appRoute = container.lookup( 'route:demos/single-model' ),
appController,
ajaxAdapter = container.lookup( 'adapter:ajax' ),
store = container.lookup( 'store:main' );
- expect( 3 );
+ assert.expect( 3 );
- equal( appRoute.get( 'store' ), store );
- equal( ajaxAdapter.get( 'store' ), store );
+ assert.equal( appRoute.get( 'store' ), store );
+ assert.equal( ajaxAdapter.get( 'store' ), store );
visit( '/' ).then(function() {
appController = container.lookup( 'controller:application' );
- equal( appController.get( 'store' ), store );
+ assert.equal( appController.get( 'store' ), store );
});
});
diff --git a/tests/unit/model-test.js b/tests/unit/model-test.js
index 5bc4370..fdf983b 100755
--- a/tests/unit/model-test.js
+++ b/tests/unit/model-test.js
@@ -35,7 +35,7 @@ var foo,
});
module( 'Unit - sl-ember-store/model', {
- setup: function() {
+ beforeEach: function() {
Foo.reopenClass({
url :'/foo',
@@ -117,7 +117,7 @@ module( 'Unit - sl-ember-store/model', {
container: container
});
},
- teardown: function() {
+ afterEach: function() {
adapter.save.reset();
adapter.deleteRecord.reset();
foo = Foo.create({
@@ -137,83 +137,83 @@ module( 'Unit - sl-ember-store/model', {
}
});
-test( 'getUrlForEndpointAction:should return /bar for ( null, `get` )', function() {
- equal( Bar.getUrlForEndpointAction( null, 'get' ), '/bar' );
+test( 'getUrlForEndpointAction:should return /bar for ( null, `get` )', function( assert ) {
+ assert.equal( Bar.getUrlForEndpointAction( null, 'get' ), '/bar' );
});
-test( 'getUrlForEndpointAction:should return /barUpdate for ( null, `post` )', function() {
- equal( Bar.getUrlForEndpointAction( null, 'post' ), '/barUpdate' );
+test( 'getUrlForEndpointAction:should return /barUpdate for ( null, `post` )', function( assert ) {
+ assert.equal( Bar.getUrlForEndpointAction( null, 'post' ), '/barUpdate' );
});
-test( 'getUrlForEndpointAction:should return /barDelete for ( null, `delete` )', function() {
- equal( Bar.getUrlForEndpointAction( null, 'delete' ), '/barDelete' );
+test( 'getUrlForEndpointAction:should return /barDelete for ( null, `delete` )', function( assert ) {
+ assert.equal( Bar.getUrlForEndpointAction( null, 'delete' ), '/barDelete' );
});
-test( 'getUrlForEndpointAction:should return /bar for ( `default`, `get` )', function() {
- equal( Bar.getUrlForEndpointAction( 'default', 'get' ), '/bar' );
+test( 'getUrlForEndpointAction:should return /bar for ( `default`, `get` )', function( assert ) {
+ assert.equal( Bar.getUrlForEndpointAction( 'default', 'get' ), '/bar' );
});
-test( 'getUrlForEndpointAction:should return /barUpdate for ( `default`, `post` )', function() {
- equal( Bar.getUrlForEndpointAction( 'default', 'post' ), '/barUpdate' );
+test( 'getUrlForEndpointAction:should return /barUpdate for ( `default`, `post` )', function( assert ) {
+ assert.equal( Bar.getUrlForEndpointAction( 'default', 'post' ), '/barUpdate' );
});
-test( 'getUrlForEndpointAction:should return /barDelete for ( `default`, `delete` )', function() {
- equal( Bar.getUrlForEndpointAction( 'default', 'delete' ), '/barDelete' );
+test( 'getUrlForEndpointAction:should return /barDelete for ( `default`, `delete` )', function( assert ) {
+ assert.equal( Bar.getUrlForEndpointAction( 'default', 'delete' ), '/barDelete' );
});
-test( 'getUrlForEndpointAction:should return /bar for ( `car`, `get` )', function() {
- equal( Bar.getUrlForEndpointAction( 'car', 'get' ), '/bar' );
+test( 'getUrlForEndpointAction:should return /bar for ( `car`, `get` )', function( assert ) {
+ assert.equal( Bar.getUrlForEndpointAction( 'car', 'get' ), '/bar' );
});
-test( 'getUrlForEndpointAction:should return /carUpdate for ( `car`, `post` )', function() {
- equal( Bar.getUrlForEndpointAction( 'car', 'post' ), '/carUpdate' );
+test( 'getUrlForEndpointAction:should return /carUpdate for ( `car`, `post` )', function( assert ) {
+ assert.equal( Bar.getUrlForEndpointAction( 'car', 'post' ), '/carUpdate' );
});
-test( 'getUrlForEndpointAction:should return /carDelete for ( `car`, `delete` )', function() {
- equal( Bar.getUrlForEndpointAction( 'car', 'delete' ), '/carDelete' );
+test( 'getUrlForEndpointAction:should return /carDelete for ( `car`, `delete` )', function( assert ) {
+ assert.equal( Bar.getUrlForEndpointAction( 'car', 'delete' ), '/carDelete' );
});
-test( 'callSerializerForEndpointAction:should return testResponse1 for TestModel - ( `null`, `get` ) ', function() {
+test( 'callSerializerForEndpointAction:should return testResponse1 for TestModel - ( `null`, `get` ) ', function( assert ) {
var testResponse = TestModel.callSerializerForEndpointAction( null, 'get', {} );
- equal( testResponse, testResponse1 );
+ assert.equal( testResponse, testResponse1 );
});
-test( 'callSerializerForEndpointAction:should return testResponse1 for TestModel - ( `test`, `get` ) ', function() {
+test( 'callSerializerForEndpointAction:should return testResponse1 for TestModel - ( `test`, `get` ) ', function( assert ) {
var testResponse = TestModel.callSerializerForEndpointAction( 'test', 'get', {} );
- equal( testResponse, testResponse2 );
+ assert.equal( testResponse, testResponse2 );
});
-test( 'save-default:should call adapter.save with correct arguments', function() {
- expect(2);
+test( 'save-default:should call adapter.save with correct arguments', function( assert ) {
+ assert.expect(2);
foo.save().then( function() {
- equal( adapter.save.args[0][0], '/foo' );
- equal( adapter.save.args[0][1].test, 'foo' );
+ assert.equal( adapter.save.args[0][0], '/foo' );
+ assert.equal( adapter.save.args[0][1].test, 'foo' );
});
});
-test( 'save-default:should update its content with fooResponse', function() {
- expect(1);
+test( 'save-default:should update its content with fooResponse', function( assert ) {
+ assert.expect(1);
foo.save().then(function() {
- deepEqual( foo.get('content'), fooResponse );
+ assert.deepEqual( foo.get('content'), fooResponse );
});
});
-test( 'save-endpoint:should call adapter.save with correct arguments', function() {
- expect(2);
+test( 'save-endpoint:should call adapter.save with correct arguments', function( assert ) {
+ assert.expect(2);
bar.save().then( function() {
- equal( adapter.save.args[0][0], '/barUpdate' );
- equal( adapter.save.args[0][1].test, 'bar' );
+ assert.equal( adapter.save.args[0][0], '/barUpdate' );
+ assert.equal( adapter.save.args[0][1].test, 'bar' );
});
});
-test( 'save-endpoint:should update its content with fooResponse', function() {
- expect(1);
+test( 'save-endpoint:should update its content with fooResponse', function( assert ) {
+ assert.expect(1);
bar.save().then( function() {
- deepEqual( bar.get('content'), fooResponse );
+ assert.deepEqual( bar.get('content'), fooResponse );
});
});
-test( 'save-endpoint:car: should call adapter.save with correct arguments', function() {
- expect(2);
+test( 'save-endpoint:car: should call adapter.save with correct arguments', function( assert ) {
+ assert.expect(2);
bar = Bar.create({
content: {
test: 'bar',
@@ -222,12 +222,12 @@ test( 'save-endpoint:car: should call adapter.save with correct arguments', func
container: container
});
bar.save({endpoint:'car'}).then( function() {
- equal( adapter.save.args[0][0], '/carUpdate' );
- equal( adapter.save.args[0][1].test, 'bar' );
+ assert.equal( adapter.save.args[0][0], '/carUpdate' );
+ assert.equal( adapter.save.args[0][1].test, 'bar' );
});
});
-test( 'save-endpoint:car: should update its content with fooResponse', function() {
+test( 'save-endpoint:car: should update its content with fooResponse', function( assert ) {
bar = Bar.create({
content: {
test: 'bar',
@@ -236,49 +236,49 @@ test( 'save-endpoint:car: should update its content with fooResponse', function(
container: container
});
bar.save({endpoint:'car'}).then( function() {
- deepEqual( bar.get('content'), fooResponse );
+ assert.deepEqual( bar.get('content'), fooResponse );
});
});
-test( 'delete: should call adapter.deleteRecord with correct arguments', function() {
- expect(1);
+test( 'delete: should call adapter.deleteRecord with correct arguments', function( assert ) {
+ assert.expect(1);
foo.deleteRecord().then( function() {
- ok( adapter.deleteRecord.calledWith( '/foo' ) );
+ assert.ok( adapter.deleteRecord.calledWith( '/foo' ) );
});
});
-test( 'delete: should destroy foo', function() {
- expect(1);
+test( 'delete: should destroy foo', function( assert ) {
+ assert.expect(1);
foo.deleteRecord().then( function() {
- ok( foo.isDestroyed );
+ assert.ok( foo.isDestroyed );
});
});
-test( 'delete-endpoint: should call adapter.delete with correct arguments', function() {
- expect(1);
+test( 'delete-endpoint: should call adapter.delete with correct arguments', function( assert ) {
+ assert.expect(1);
bar.deleteRecord().then( function() {
- ok( adapter.deleteRecord.calledWith( '/barDelete' ) );
+ assert.ok( adapter.deleteRecord.calledWith( '/barDelete' ) );
});
});
-test( 'delete-endpoint: should destroy bar', function() {
- expect(1);
+test( 'delete-endpoint: should destroy bar', function( assert ) {
+ assert.expect(1);
bar.deleteRecord().then( function() {
- ok( bar.isDestroyed );
+ assert.ok( bar.isDestroyed );
});
});
-test( 'delete-endpoint:car: should call adapter.delete with correct arguments', function() {
- expect(1);
+test( 'delete-endpoint:car: should call adapter.delete with correct arguments', function( assert ) {
+ assert.expect(1);
bar.deleteRecord({endpoint:'car'}).then( function() {
- ok( adapter.deleteRecord.calledWith( '/carDelete' ) );
+ assert.ok( adapter.deleteRecord.calledWith( '/carDelete' ) );
});
});
-test( 'delete-endpoint:car: should destroy bar', function() {
- expect(1);
+test( 'delete-endpoint:car: should destroy bar', function( assert ) {
+ assert.expect(1);
bar.deleteRecord({endpoint:'car'}).then( function() {
- ok( bar.isDestroyed );
+ assert.ok( bar.isDestroyed );
});
});
diff --git a/tests/unit/store-test.js b/tests/unit/store-test.js
index b5b37fc..9860de3 100755
--- a/tests/unit/store-test.js
+++ b/tests/unit/store-test.js
@@ -13,7 +13,7 @@ var Foo,
module( 'Unit - sl-ember-store/store', {
- setup: function() {
+ beforeEach: function() {
Foo = Model.extend();
Bar = Model.extend();
Bar.reopenClass({ adapter: 'localstorage' });
@@ -64,7 +64,7 @@ module( 'Unit - sl-ember-store/store', {
sinon.spy( Foo, 'create' );
queryHook = sinon.spy();
},
- teardown: function() {
+ afterEach: function() {
store.__find.restore();
store.modelFor.restore();
store.adapterFor.restore();
@@ -74,85 +74,85 @@ module( 'Unit - sl-ember-store/store', {
}
});
-test( 'modelFor: should return the model "Foo" for type "foo" ', function() {
- ok( store.modelFor( 'foo' ) === Foo );
+test( 'modelFor: should return the model "Foo" for type "foo" ', function( assert ) {
+ assert.ok( store.modelFor( 'foo' ) === Foo );
});
-test( 'modelFor: should return the model "Bar" for type "bar" ', function() {
- ok( store.modelFor( 'bar' ) === Bar );
+test( 'modelFor: should return the model "Bar" for type "bar" ', function( assert ) {
+ assert.ok( store.modelFor( 'bar' ) === Bar );
});
-test( 'adapterFor: should return the adapter ajax for model type foo', function() {
- ok( store.adapterFor( 'foo' ) instanceof AjaxAdapter );
+test( 'adapterFor: should return the adapter ajax for model type foo', function( assert ) {
+ assert.ok( store.adapterFor( 'foo' ) instanceof AjaxAdapter );
});
-test( 'adapterFor: should return the adapter localstorage for model type bar', function() {
- ok( store.adapterFor( 'bar' ) instanceof LocalstorageAdapter );
+test( 'adapterFor: should return the adapter localstorage for model type bar', function( assert ) {
+ assert.ok( store.adapterFor( 'bar' ) instanceof LocalstorageAdapter );
});
-test( 'findOne: should call __find with correct args', function() {
+test( 'findOne: should call __find with correct args', function( assert ) {
var options = { "otherId":1 },
args;
store.findOne( 'foo', options );
- ok( store.__find.calledWith( 'foo', null, options, true ) );
+ assert.ok( store.__find.calledWith( 'foo', null, options, true ) );
});
-test( 'find should call __find with numeric id', function() {
+test( 'find should call __find with numeric id', function( assert ) {
var options = { "otherId": 1 };
store.find( 'foo', 1, options );
- ok( store.__find.calledWith( 'foo', 1, options, false ) );
+ assert.ok( store.__find.calledWith( 'foo', 1, options, false ) );
});
-test( 'find should call __find with object for first param', function() {
+test( 'find should call __find with object for first param', function( assert ) {
var options = { "otherId": 1 };
store.find( 'foo', options );
- ok( store.__find.calledWith( 'foo', null, options, false ) );
+ assert.ok( store.__find.calledWith( 'foo', null, options, false ) );
});
-test( 'find should call __find with only the type', function() {
+test( 'find should call __find with only the type', function( assert ) {
store.find( 'foo' );
- ok( store.__find.calledWith( 'foo', null, null, false ) );
+ assert.ok( store.__find.calledWith( 'foo', null, null, false ) );
});
-test( '__find should have called modelFor', function() {
+test( '__find should have called modelFor', function( assert ) {
store.__find( 'foo', 1, {}, false );
- ok( store.modelFor.calledWith( 'foo' ) );
+ assert.ok( store.modelFor.calledWith( 'foo' ) );
});
-test( '__find should have called adapterFor', function() {
+test( '__find should have called adapterFor', function( assert ) {
store.__find( 'foo', 1, {}, false );
- ok( store.adapterFor.calledWith( 'foo' ) );
+ assert.ok( store.adapterFor.calledWith( 'foo' ) );
});
-test( '__find should have called AjaxAdapter.find', function() {
+test( '__find should have called AjaxAdapter.find', function( assert ) {
store.__find( 'foo', 1, {}, false );
- ok( ajaxAdapter.find.calledWith( 'foo', 1, {}, false ) );
+ assert.ok( ajaxAdapter.find.calledWith( 'foo', 1, {}, false ) );
});
-test( 'createRecord should have called modelFor', function() {
+test( 'createRecord should have called modelFor', function( assert ) {
store.createRecord( 'foo' );
- ok( store.modelFor.calledWith( 'foo' ) );
+ assert.ok( store.modelFor.calledWith( 'foo' ) );
});
-test( 'createRecord should have called Foo.create once', function() {
+test( 'createRecord should have called Foo.create once', function( assert ) {
store.createRecord( 'foo' );
- ok( Foo.create.calledOnce );
+ assert.ok( Foo.create.calledOnce );
});
-test( 'createRecord should have called Foo.create with an object container', function() {
+test( 'createRecord should have called Foo.create with an object container', function( assert ) {
store.createRecord( 'foo' );
- ok( Foo.create.calledWith( { container: store.container } ) );
+ assert.ok( Foo.create.calledWith( { container: store.container } ) );
});
-test( 'registerPreQueryHook should add an entry to preQueryHooks', function() {
+test( 'registerPreQueryHook should add an entry to preQueryHooks', function( assert ) {
store.registerPreQueryHook( queryHook );
- ok( store.get( 'preQueryHooks' ).length === 1 );
+ assert.ok( store.get( 'preQueryHooks' ).length === 1 );
});
-test( 'runPreQueryHooks should run query hook once', function() {
+test( 'runPreQueryHooks should run query hook once', function( assert ) {
store.registerPostQueryHook( queryHook );
store.runPostQueryHooks();
- ok( queryHook.calledOnce );
+ assert.ok( queryHook.calledOnce );
});