diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js index 249a036f..b5da23be 100644 --- a/tests/dummy/config/environment.js +++ b/tests/dummy/config/environment.js @@ -55,6 +55,7 @@ module.exports = function(environment) { ENV.APP.rootElement = '#ember-testing'; // URL of the backend running in docker + // With nginx 'https://localhost/odata' var testODataServiceURL = 'http://localhost:80/odata'; ENV.APP.testODataService = !!testODataServiceURL; diff --git a/tests/integration/adapters/odata-test.js b/tests/integration/adapters/odata-test.js index bc03165d..03091d66 100644 --- a/tests/integration/adapters/odata-test.js +++ b/tests/integration/adapters/odata-test.js @@ -19,139 +19,139 @@ if (config.APP.testODataService) { } } - module('Integration | Adapter | odata', { - beforeEach() { + module('Integration | Adapter | odata', function(hooks) { + hooks.beforeEach(function() { App = startApp(); App.register('adapter:application', OdataAdapter.extend({ host: baseUrl })); store = App.__container__.lookup('service:store'); odataAdapter = store.adapterFor('application'); - }, + }); - afterEach() { + hooks.afterEach(function() { Ember.run(App, 'destroy'); - }, - }); + }); - test('check method returns typed result', function(assert) { - let done = assert.async(); + test('check method returns typed result', function(assert) { + let done = assert.async(); - Ember.run(() => { - odataAdapter.callAction({ - actionName: 'ODataTestTypedResult', - data: null, - store: store, - modelName: 'ember-flexberry-dummy-application-user', - url: baseUrl - }) - .then((records) => { - assert.equal(records.length, 3); - assert.equal(records[0].constructor.modelName, 'ember-flexberry-dummy-application-user'); - assert.equal(Ember.get(records[0], 'name'), 'TestName1'); - assert.equal(Ember.get(records[0], 'eMail'), 'TestEmail1'); - assert.equal(records[1].constructor.modelName, 'ember-flexberry-dummy-application-user'); - assert.equal(Ember.get(records[1], 'name'), 'TestName2'); - assert.equal(Ember.get(records[1], 'eMail'), 'TestEmail2'); - assert.equal(records[2].constructor.modelName, 'ember-flexberry-dummy-application-user'); - assert.equal(Ember.get(records[2], 'name'), 'TestName3'); - assert.equal(Ember.get(records[2], 'eMail'), 'TestEmail3'); - }) - .finally(done); + Ember.run(() => { + odataAdapter.callAction({ + actionName: 'ODataTestTypedResult', + data: null, + store: store, + modelName: 'ember-flexberry-dummy-application-user', + url: baseUrl + }) + .then((records) => { + assert.equal(records.length, 3); + assert.equal(records[0].constructor.modelName, 'ember-flexberry-dummy-application-user'); + assert.equal(Ember.get(records[0], 'name'), 'TestName1'); + assert.equal(Ember.get(records[0], 'eMail'), 'TestEmail1'); + assert.equal(records[1].constructor.modelName, 'ember-flexberry-dummy-application-user'); + assert.equal(Ember.get(records[1], 'name'), 'TestName2'); + assert.equal(Ember.get(records[1], 'eMail'), 'TestEmail2'); + assert.equal(records[2].constructor.modelName, 'ember-flexberry-dummy-application-user'); + assert.equal(Ember.get(records[2], 'name'), 'TestName3'); + assert.equal(Ember.get(records[2], 'eMail'), 'TestEmail3'); + }) + .finally(done); + }); }); - }); - test('check method returns not typed result', function(assert) { - let done = assert.async(); + test('check method returns not typed result', function(assert) { + let done = assert.async(); - Ember.run(() => { - odataAdapter.callAction({ - actionName: 'ODataTestNotTypedResult', - data: null, - store: store, - modelName: 'ember-flexberry-dummy-application-user', - url: baseUrl - }) - .then((records) => { - assert.equal(records.length, 3); - assert.equal(records[0].constructor.modelName, 'ember-flexberry-dummy-application-user'); - assert.equal(Ember.get(records[0], 'name'), 'TestName1'); - assert.equal(Ember.get(records[0], 'eMail'), 'TestEmail1'); - assert.equal(records[1].constructor.modelName, 'ember-flexberry-dummy-application-user'); - assert.equal(Ember.get(records[1], 'name'), 'TestName2'); - assert.equal(Ember.get(records[1], 'eMail'), 'TestEmail2'); - assert.equal(records[2].constructor.modelName, 'ember-flexberry-dummy-application-user'); - assert.equal(Ember.get(records[2], 'name'), 'TestName3'); - assert.equal(Ember.get(records[2], 'eMail'), 'TestEmail3'); - }) - .finally(done); + Ember.run(() => { + odataAdapter.callAction({ + actionName: 'ODataTestNotTypedResult', + data: null, + store: store, + modelName: 'ember-flexberry-dummy-application-user', + url: baseUrl + }) + .then((records) => { + assert.equal(records.length, 3); + assert.equal(records[0].constructor.modelName, 'ember-flexberry-dummy-application-user'); + assert.equal(Ember.get(records[0], 'name'), 'TestName1'); + assert.equal(Ember.get(records[0], 'eMail'), 'TestEmail1'); + assert.equal(records[1].constructor.modelName, 'ember-flexberry-dummy-application-user'); + assert.equal(Ember.get(records[1], 'name'), 'TestName2'); + assert.equal(Ember.get(records[1], 'eMail'), 'TestEmail2'); + assert.equal(records[2].constructor.modelName, 'ember-flexberry-dummy-application-user'); + assert.equal(Ember.get(records[2], 'name'), 'TestName3'); + assert.equal(Ember.get(records[2], 'eMail'), 'TestEmail3'); + }) + .finally(done); + }); }); - }); - test('check method returns multy typed result', function(assert) { - let done = assert.async(); - let applicationSerializer = store.serializerFor('application'); - Ember.set(applicationSerializer, 'primaryKey', '__PrimaryKey'); + test('check method returns multy typed result', function(assert) { + let done = assert.async(); + let applicationSerializer = store.serializerFor('application'); + Ember.set(applicationSerializer, 'primaryKey', '__PrimaryKey'); - Ember.run(() => { - odataAdapter.callAction({ - actionName: 'ODataTestMultyTypedResult', - data: null, - store: store, - modelName: 'model', - url: baseUrl - }) - .then((records) => { - assert.equal(records.length, 3); - assert.equal(records[0].constructor.modelName, 'ember-flexberry-dummy-application-user'); - assert.equal(Ember.get(records[0], 'name'), 'TestUserName'); - assert.equal(Ember.get(records[0], 'eMail'), 'TestUserEmail'); - assert.equal(records[1].constructor.modelName, 'ember-flexberry-dummy-suggestion'); - assert.equal(Ember.get(records[1], 'address'), 'TestSuggestionAddress'); - assert.equal(Ember.get(records[1], 'text'), 'TestSuggestionText'); - assert.equal(records[2].constructor.modelName, 'ember-flexberry-dummy-suggestion-type'); - assert.equal(Ember.get(records[2], 'name'), 'TestSuggestionTypeName'); - }) - .finally(done); + Ember.run(() => { + odataAdapter.callAction({ + actionName: 'ODataTestMultyTypedResult', + data: null, + store: store, + modelName: 'model', + url: baseUrl + }) + .then((records) => { + assert.equal(records.length, 3); + assert.equal(records[0].constructor.modelName, 'ember-flexberry-dummy-application-user'); + assert.equal(Ember.get(records[0], 'name'), 'TestUserName'); + assert.equal(Ember.get(records[0], 'eMail'), 'TestUserEmail'); + assert.equal(records[1].constructor.modelName, 'ember-flexberry-dummy-suggestion'); + assert.equal(Ember.get(records[1], 'address'), 'TestSuggestionAddress'); + assert.equal(Ember.get(records[1], 'text'), 'TestSuggestionText'); + assert.equal(records[2].constructor.modelName, 'ember-flexberry-dummy-suggestion-type'); + assert.equal(Ember.get(records[2], 'name'), 'TestSuggestionTypeName'); + }) + .finally(done); + }); }); - }); - test('check method returns multy typed linked result', function(assert) { - let done = assert.async(); - let applicationSerializer = store.serializerFor('application'); - Ember.set(applicationSerializer, 'primaryKey', '__PrimaryKey'); + test('check method returns multy typed linked result', function(assert) { + let done = assert.async(); + let applicationSerializer = store.serializerFor('application'); + Ember.set(applicationSerializer, 'primaryKey', '__PrimaryKey'); - Ember.run(() => { - odataAdapter.callAction({ - actionName: 'ODataTestMultyTypedWithLinksResult', - data: null, - store: store, - modelName: 'model', - url: baseUrl - }) - .then((records) => { - // OData actions not return masters yet. - assert.equal(records.length, 2); - assert.equal(records[0].constructor.modelName, 'ember-flexberry-dummy-application-user'); - assert.equal(Ember.get(records[0], 'name'), 'TestUserName'); - assert.equal(Ember.get(records[0], 'eMail'), 'TestUserEmail'); - assert.equal(records[1].constructor.modelName, 'ember-flexberry-dummy-suggestion'); - assert.equal(Ember.get(records[1], 'address'), 'TestSuggestionAddress'); - assert.equal(Ember.get(records[1], 'text'), 'TestSuggestionText'); - }) - .finally(done); + Ember.run(() => { + odataAdapter.callAction({ + actionName: 'ODataTestMultyTypedWithLinksResult', + data: null, + store: store, + modelName: 'model', + url: baseUrl + }) + .then((records) => { + // OData actions not return masters yet. + assert.equal(records.length, 2); + assert.equal(records[0].constructor.modelName, 'ember-flexberry-dummy-application-user'); + assert.equal(Ember.get(records[0], 'name'), 'TestUserName'); + assert.equal(Ember.get(records[0], 'eMail'), 'TestUserEmail'); + assert.equal(records[1].constructor.modelName, 'ember-flexberry-dummy-suggestion'); + assert.equal(Ember.get(records[1], 'address'), 'TestSuggestionAddress'); + assert.equal(Ember.get(records[1], 'text'), 'TestSuggestionText'); + }) + .finally(done); + }); }); - }); - test('check method throws exception when model is not defined', function(assert) { - Ember.run(() => { - assert.throws( - odataAdapter.callAction({ - actionName: 'ODataTestTypedResult', - data: null, - store: store, - modelName: null, - url: baseUrl - })); + test('check method throws exception when model is not defined', function(assert) { + Ember.run(() => { + assert.throws( + odataAdapter.callAction({ + actionName: 'ODataTestTypedResult', + data: null, + store: store, + modelName: null, + url: baseUrl + })); + }); }); }); } diff --git a/tests/integration/display-deep-model-test.js b/tests/integration/display-deep-model-test.js index 6c88a2ad..1ffcdb65 100644 --- a/tests/integration/display-deep-model-test.js +++ b/tests/integration/display-deep-model-test.js @@ -8,8 +8,8 @@ let AppDisplayDeepModel; let storeDisplayDeepModel; const dbNameDisplayDeepModel = 'TestDbDDM'; -module('Display deep model', { - beforeEach: function (assert) { +module('Display deep model', function(hooks) { + hooks.beforeEach(function(assert) { let done = assert.async(); run(function () { @@ -103,34 +103,34 @@ module('Display deep model', { }).finally(done); }).catch(done); }); - }, + }); - afterEach: function () { + hooks.afterEach(function() { run(function () { let dexieService = AppDisplayDeepModel.__container__.lookup('service:dexie'); dexieService.close(dbNameDisplayDeepModel); destroyApp(AppDisplayDeepModel); }); - } -}); + }); -test('find suggestion', function (assert) { - assert.expect(8); + test('find suggestion', function (assert) { + assert.expect(8); - visit('/suggestion/fea5b275-cb9b-4584-ba04-26122bc8cbd3'); - andThen(function () { - let done = assert.async(); - run.later(function() { - assert.equal(find('div.address').text(), 'Street, 20'); - assert.equal(find('div.votes').text(), '1'); - assert.equal(find('div.author').text(), 'Васиииилий'); - assert.equal(find('div.type').text(), '123'); - assert.equal(find('div.parent-type').text(), 'Type #8'); - assert.equal(find('div.comment').text(), 'Not ok'); - assert.equal(find('div.comment-author').text(), 'Васиииилий'); - assert.equal(find('div.comment-vote-type').text(), 'Dislike'); + visit('/suggestion/fea5b275-cb9b-4584-ba04-26122bc8cbd3'); + andThen(function () { + let done = assert.async(); + run.later(function() { + assert.equal(find('div.address').text(), 'Street, 20'); + assert.equal(find('div.votes').text(), '1'); + assert.equal(find('div.author').text(), 'Васиииилий'); + assert.equal(find('div.type').text(), '123'); + assert.equal(find('div.parent-type').text(), 'Type #8'); + assert.equal(find('div.comment').text(), 'Not ok'); + assert.equal(find('div.comment-author').text(), 'Васиииилий'); + assert.equal(find('div.comment-vote-type').text(), 'Dislike'); - done(); - }, 300); + done(); + }, 300); + }); }); }); diff --git a/tests/integration/services/store-test.js b/tests/integration/services/store-test.js index 48a64e97..6dae78be 100644 --- a/tests/integration/services/store-test.js +++ b/tests/integration/services/store-test.js @@ -1,35 +1,35 @@ import { run } from '@ember/runloop'; -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; import startApp from 'dummy/tests/helpers/start-app'; let App; -moduleFor('service:store', 'Integration | Service | store', { - beforeEach() { +module('Integration | Service | store', function(hooks) { + hooks.beforeEach(function() { App = startApp(); - }, + }); - afterEach() { + hooks.afterEach(function() { run(App, 'destroy'); - }, -}); + }); -test('create unload create', function(assert) { - let done = assert.async(); - run(() => { - let store = App.__container__.lookup('service:store'); - store.get('offlineGlobals').setOnlineAvailable(false); - store.createRecord('ember-flexberry-dummy-application-user', { - name: 'Man', - eMail: 'man@example.com', - }).save().then((record) => { - let id = record.get('id'); - store.unloadRecord(record); - assert.ok(store.createRecord('ember-flexberry-dummy-application-user', { - id: id, - name: 'SuperMan', - eMail: 'super.man@example.com', - }), 'It is a place for SuperMan.'); - }).finally(done); + test('create unload create', function(assert) { + let done = assert.async(); + run(() => { + let store = App.__container__.lookup('service:store'); + store.get('offlineGlobals').setOnlineAvailable(false); + store.createRecord('ember-flexberry-dummy-application-user', { + name: 'Man', + eMail: 'man@example.com', + }).save().then((record) => { + let id = record.get('id'); + store.unloadRecord(record); + assert.ok(store.createRecord('ember-flexberry-dummy-application-user', { + id: id, + name: 'SuperMan', + eMail: 'super.man@example.com', + }), 'It is a place for SuperMan.'); + }).finally(done); + }); }); }); diff --git a/tests/integration/services/syncer-test.js b/tests/integration/services/syncer-test.js index e25f18eb..e3c8b762 100644 --- a/tests/integration/services/syncer-test.js +++ b/tests/integration/services/syncer-test.js @@ -2,7 +2,7 @@ import { run } from '@ember/runloop'; import RSVP from 'rsvp'; import DS from 'ember-data'; import Dexie from 'npm:dexie'; -import { moduleFor, skip, test } from 'ember-qunit'; +import { module, skip, test } from 'qunit'; import OdataAdapter from 'ember-flexberry-data/adapters/odata'; import Builder from 'ember-flexberry-data/query/builder'; import config from 'dummy/config/environment'; @@ -20,162 +20,31 @@ if (config.APP.testODataService) { } } - moduleFor('service:syncer', 'Integration | Service | syncer', { - needs: [ - 'model:ember-flexberry-dummy-application-user', - ], - - beforeEach(assert) { + module('Integration | Service | syncer', function(hooks) { + hooks.beforeEach(function(assert) { let done = assert.async(); Dexie.delete('TestDB').then(() => { App = startApp(); App.register('adapter:application', OdataAdapter.extend({ host: baseUrl })); done(); }); - }, - - afterEach() { - run(App, 'destroy'); - }, - }); - - test('create and sync without audit', function(assert) { - runTest(App, 2, assert, (store, syncer, done) => { - syncer.set('auditEnabled', false); - store.get('offlineGlobals').setOnlineAvailable(false); - store.createRecord('ember-flexberry-dummy-application-user', { - name: 'Man', - eMail: 'man@example.com', - }).save().then((user) => { - user.set('name', 'SuperMan'); - user.set('eMail', 'super.man@example.com'); - return user.save().then(() => { - store.get('offlineGlobals').setOnlineAvailable(true); - return syncer.syncUp().then((result) => { - assert.equal(result, 1, 'Only one operation was executed.'); - let builder = new Builder(store, 'ember-flexberry-dummy-application-user') - .selectByProjection('ApplicationUserE') - .byId(user.get('id')); - return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { - assert.equal(onlineRecord.get('name'), 'SuperMan', 'Now SuperMan is omnipresent.'); - return new RSVP.resolve(onlineRecord); - }); - }); - }); - }).then(user => user.destroyRecord()).finally(done); - }); - }); - - test('create and sync with audit', function(assert) { - runTest(App, 2, assert, (store, syncer, done) => { - store.get('offlineGlobals').setOnlineAvailable(false); - store.createRecord('ember-flexberry-dummy-application-user', { - name: 'Man', - eMail: 'man@example.com', - }).save().then((user) => { - user.set('name', 'SuperMan'); - user.set('eMail', 'super.man@example.com'); - return user.save().then(() => { - store.get('offlineGlobals').setOnlineAvailable(true); - return syncer.syncUp().then((result) => { - assert.equal(result, 2, 'Two operations were executed.'); - let builder = new Builder(store, 'ember-flexberry-dummy-application-user') - .selectByProjection('ApplicationUserE') - .byId(user.get('id')); - return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { - assert.equal(onlineRecord.get('name'), 'SuperMan', 'Now SuperMan is omnipresent.'); - return new RSVP.resolve(onlineRecord); - }); - }); - }); - }).then(user => user.destroyRecord()).finally(done); - }); - }); - - test('update and sync without audit', function(assert) { - runTest(App, 3, assert, (store, syncer, done) => { - syncer.set('auditEnabled', false); - store.createRecord('ember-flexberry-dummy-application-user', { - name: 'Man', - eMail: 'man@example.com', - }).save().then(user => syncer.syncDown(user).then(() => { - store.get('offlineGlobals').setOnlineAvailable(false); - let builder = new Builder(store, 'ember-flexberry-dummy-application-user') - .selectByProjection('ApplicationUserE') - .byId(user.get('id')); - return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((offlineRecord) => { - offlineRecord.set('name', 'SuperMan'); - return offlineRecord.save().then((offlineRecord) => { - offlineRecord.set('eMail', 'super.man@example.com'); - return offlineRecord.save().then(() => { - store.get('offlineGlobals').setOnlineAvailable(true); - return syncer.syncUp().then((result) => { - assert.equal(result, 1, 'Only one operation was executed.'); - let builder = new Builder(store, 'ember-flexberry-dummy-application-user') - .selectByProjection('ApplicationUserE') - .byId(user.get('id')); - return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { - assert.equal(onlineRecord.get('name'), 'SuperMan', `Now he's SuperMan.`); - assert.equal(onlineRecord.get('eMail'), 'super.man@example.com', 'Now he has a new email address.'); - return new RSVP.resolve(onlineRecord); - }); - }); - }); - }); - }); - })).then(user => user.destroyRecord()).finally(done); }); - }); - test('update and sync with audit', function(assert) { - runTest(App, 3, assert, (store, syncer, done) => { - store.createRecord('ember-flexberry-dummy-application-user', { - name: 'Man', - eMail: 'man@example.com', - }).save().then(user => syncer.syncDown(user).then(() => { - store.get('offlineGlobals').setOnlineAvailable(false); - let builder = new Builder(store, 'ember-flexberry-dummy-application-user') - .selectByProjection('ApplicationUserE') - .byId(user.get('id')); - return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((offlineRecord) => { - offlineRecord.set('name', 'SuperMan'); - return offlineRecord.save().then((offlineRecord) => { - offlineRecord.set('eMail', 'super.man@example.com'); - return offlineRecord.save().then(() => { - store.get('offlineGlobals').setOnlineAvailable(true); - return syncer.syncUp().then((result) => { - assert.equal(result, 2, 'Two operations were executed.'); - let builder = new Builder(store, 'ember-flexberry-dummy-application-user') - .selectByProjection('ApplicationUserE') - .byId(user.get('id')); - return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { - assert.equal(onlineRecord.get('name'), 'SuperMan', `Now he's SuperMan.`); - assert.equal(onlineRecord.get('eMail'), 'super.man@example.com', 'Now he has a new email address.'); - return new RSVP.resolve(onlineRecord); - }); - }); - }); - }); - }); - })).then(user => user.destroyRecord()).finally(done); + hooks.afterEach(function() { + run(App, 'destroy'); }); - }); - test('delete and sync without audit', function(assert) { - runTest(App, 2, assert, (store, syncer, done) => { - syncer.set('auditEnabled', false); - store.createRecord('ember-flexberry-dummy-application-user', { - name: 'Man', - eMail: 'man@example.com', - }).save().then(user => syncer.syncDown(user).then(() => { + test('create and sync without audit', function(assert) { + runTest(App, 2, assert, (store, syncer, done) => { + syncer.set('auditEnabled', false); store.get('offlineGlobals').setOnlineAvailable(false); - let builder = new Builder(store, 'ember-flexberry-dummy-application-user') - .selectByProjection('ApplicationUserE') - .byId(user.get('id')); - return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((offlineRecord) => { - offlineRecord.set('name', 'SuperMan'); - offlineRecord.set('eMail', 'super.man@example.com'); - return offlineRecord.save().then(offlineRecord => offlineRecord.destroyRecord().then(() => { + store.createRecord('ember-flexberry-dummy-application-user', { + name: 'Man', + eMail: 'man@example.com', + }).save().then((user) => { + user.set('name', 'SuperMan'); + user.set('eMail', 'super.man@example.com'); + return user.save().then(() => { store.get('offlineGlobals').setOnlineAvailable(true); return syncer.syncUp().then((result) => { assert.equal(result, 1, 'Only one operation was executed.'); @@ -183,29 +52,25 @@ if (config.APP.testODataService) { .selectByProjection('ApplicationUserE') .byId(user.get('id')); return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { - assert.notOk(onlineRecord, 'SuperMan is gone.'); + assert.equal(onlineRecord.get('name'), 'SuperMan', 'Now SuperMan is omnipresent.'); + return new RSVP.resolve(onlineRecord); }); }); - })); - }); - })).finally(done); + }); + }).then(user => user.destroyRecord()).finally(done); + }); }); - }); - test('delete and sync with audit', function(assert) { - runTest(App, 2, assert, (store, syncer, done) => { - store.createRecord('ember-flexberry-dummy-application-user', { - name: 'Man', - eMail: 'man@example.com', - }).save().then(user => syncer.syncDown(user).then(() => { + test('create and sync with audit', function(assert) { + runTest(App, 2, assert, (store, syncer, done) => { store.get('offlineGlobals').setOnlineAvailable(false); - let builder = new Builder(store, 'ember-flexberry-dummy-application-user') - .selectByProjection('ApplicationUserE') - .byId(user.get('id')); - return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((offlineRecord) => { - offlineRecord.set('name', 'SuperMan'); - offlineRecord.set('eMail', 'super.man@example.com'); - return offlineRecord.save().then(offlineRecord => offlineRecord.destroyRecord().then(() => { + store.createRecord('ember-flexberry-dummy-application-user', { + name: 'Man', + eMail: 'man@example.com', + }).save().then((user) => { + user.set('name', 'SuperMan'); + user.set('eMail', 'super.man@example.com'); + return user.save().then(() => { store.get('offlineGlobals').setOnlineAvailable(true); return syncer.syncUp().then((result) => { assert.equal(result, 2, 'Two operations were executed.'); @@ -213,107 +78,238 @@ if (config.APP.testODataService) { .selectByProjection('ApplicationUserE') .byId(user.get('id')); return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { - assert.notOk(onlineRecord, 'SuperMan is gone.'); + assert.equal(onlineRecord.get('name'), 'SuperMan', 'Now SuperMan is omnipresent.'); + return new RSVP.resolve(onlineRecord); }); }); - })); - }); - })).finally(done); + }); + }).then(user => user.destroyRecord()).finally(done); + }); }); - }); - test('sync without data to sync', function(assert) { - runTest(App, 1, assert, (store, syncer, done) => { - syncer.get('auditEnabled', false); - store.get('offlineGlobals').setOnlineAvailable(true); - return syncer.syncUp().then((result) => { - assert.equal(result, undefined, 'No operation was executed and promise was resolved.'); - }).finally(done);; + test('update and sync without audit', function(assert) { + runTest(App, 3, assert, (store, syncer, done) => { + syncer.set('auditEnabled', false); + store.createRecord('ember-flexberry-dummy-application-user', { + name: 'Man', + eMail: 'man@example.com', + }).save().then(user => syncer.syncDown(user).then(() => { + store.get('offlineGlobals').setOnlineAvailable(false); + let builder = new Builder(store, 'ember-flexberry-dummy-application-user') + .selectByProjection('ApplicationUserE') + .byId(user.get('id')); + return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((offlineRecord) => { + offlineRecord.set('name', 'SuperMan'); + return offlineRecord.save().then((offlineRecord) => { + offlineRecord.set('eMail', 'super.man@example.com'); + return offlineRecord.save().then(() => { + store.get('offlineGlobals').setOnlineAvailable(true); + return syncer.syncUp().then((result) => { + assert.equal(result, 1, 'Only one operation was executed.'); + let builder = new Builder(store, 'ember-flexberry-dummy-application-user') + .selectByProjection('ApplicationUserE') + .byId(user.get('id')); + return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { + assert.equal(onlineRecord.get('name'), 'SuperMan', `Now he's SuperMan.`); + assert.equal(onlineRecord.get('eMail'), 'super.man@example.com', 'Now he has a new email address.'); + return new RSVP.resolve(onlineRecord); + }); + }); + }); + }); + }); + })).then(user => user.destroyRecord()).finally(done); + }); }); - }); - skip('sync up with server error', function(assert) { - runTest(App, 2, assert, (store, syncer, done) => { - // Not cast value and throw error. - store.modelFor('ember-flexberry-dummy-application-user').reopen({ - vip: DS.attr('string'), + test('update and sync with audit', function(assert) { + runTest(App, 3, assert, (store, syncer, done) => { + store.createRecord('ember-flexberry-dummy-application-user', { + name: 'Man', + eMail: 'man@example.com', + }).save().then(user => syncer.syncDown(user).then(() => { + store.get('offlineGlobals').setOnlineAvailable(false); + let builder = new Builder(store, 'ember-flexberry-dummy-application-user') + .selectByProjection('ApplicationUserE') + .byId(user.get('id')); + return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((offlineRecord) => { + offlineRecord.set('name', 'SuperMan'); + return offlineRecord.save().then((offlineRecord) => { + offlineRecord.set('eMail', 'super.man@example.com'); + return offlineRecord.save().then(() => { + store.get('offlineGlobals').setOnlineAvailable(true); + return syncer.syncUp().then((result) => { + assert.equal(result, 2, 'Two operations were executed.'); + let builder = new Builder(store, 'ember-flexberry-dummy-application-user') + .selectByProjection('ApplicationUserE') + .byId(user.get('id')); + return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { + assert.equal(onlineRecord.get('name'), 'SuperMan', `Now he's SuperMan.`); + assert.equal(onlineRecord.get('eMail'), 'super.man@example.com', 'Now he has a new email address.'); + return new RSVP.resolve(onlineRecord); + }); + }); + }); + }); + }); + })).then(user => user.destroyRecord()).finally(done); }); + }); - store.get('offlineGlobals').setOnlineAvailable(false); - return store.createRecord('ember-flexberry-dummy-application-user', { - name: 'SuperMan', - eMail: 'super.man@example.com', - vip: 'invalid', - }).save().then((user) => { - store.get('offlineGlobals').setOnlineAvailable(true); - return syncer.syncUp().catch((rejectedJob) => { - assert.equal(rejectedJob.get('executionResult'), 'Ошибка', 'Job not executed.'); + test('delete and sync without audit', function(assert) { + runTest(App, 2, assert, (store, syncer, done) => { + syncer.set('auditEnabled', false); + store.createRecord('ember-flexberry-dummy-application-user', { + name: 'Man', + eMail: 'man@example.com', + }).save().then(user => syncer.syncDown(user).then(() => { + store.get('offlineGlobals').setOnlineAvailable(false); let builder = new Builder(store, 'ember-flexberry-dummy-application-user') .selectByProjection('ApplicationUserE') .byId(user.get('id')); - return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { - assert.notOk(onlineRecord, 'SuperMan is not there.'); + return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((offlineRecord) => { + offlineRecord.set('name', 'SuperMan'); + offlineRecord.set('eMail', 'super.man@example.com'); + return offlineRecord.save().then(offlineRecord => offlineRecord.destroyRecord().then(() => { + store.get('offlineGlobals').setOnlineAvailable(true); + return syncer.syncUp().then((result) => { + assert.equal(result, 1, 'Only one operation was executed.'); + let builder = new Builder(store, 'ember-flexberry-dummy-application-user') + .selectByProjection('ApplicationUserE') + .byId(user.get('id')); + return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { + assert.notOk(onlineRecord, 'SuperMan is gone.'); + }); + }); + })); }); - }); - }).finally(done); + })).finally(done); + }); }); - }); - skip('sync up with not found record', function(assert) { - runTest(App, 3, assert, (store, syncer, done) => { - store.createRecord('ember-flexberry-dummy-application-user', { - name: 'Man', - eMail: 'man@example.com', - }).save().then((user) => { - let id = user.get('id'); - return syncer.syncDown(user).then(() => { + test('delete and sync with audit', function(assert) { + runTest(App, 2, assert, (store, syncer, done) => { + store.createRecord('ember-flexberry-dummy-application-user', { + name: 'Man', + eMail: 'man@example.com', + }).save().then(user => syncer.syncDown(user).then(() => { store.get('offlineGlobals').setOnlineAvailable(false); let builder = new Builder(store, 'ember-flexberry-dummy-application-user') .selectByProjection('ApplicationUserE') - .byId(id); + .byId(user.get('id')); return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((offlineRecord) => { offlineRecord.set('name', 'SuperMan'); offlineRecord.set('eMail', 'super.man@example.com'); - return offlineRecord.save().then(() => { + return offlineRecord.save().then(offlineRecord => offlineRecord.destroyRecord().then(() => { store.get('offlineGlobals').setOnlineAvailable(true); - let builder = new Builder(store, 'ember-flexberry-dummy-application-user') - .selectByProjection('ApplicationUserE') - .byId(id); - return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { - assert.notEqual(onlineRecord.get('name'), 'SuperMan', `He was still an ordinary person.`); - return onlineRecord.destroyRecord().then(() => { - let options = { continueOnError: true }; - return syncer.syncUp(null, options).then((result) => { - assert.equal(result, 0, 'He never managed to become a SuperMan.'); - let query = new Builder(store, 'i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity') - .select('id,objectPrimaryKey,operationType,executionResult,objectType,auditFields') - .where('objectPrimaryKey', 'eq', id).build(); - return store.queryRecord(query.modelName, query).then((auditEntity) => { - assert.deepEqual({ - objectPrimaryKey: auditEntity.get('objectPrimaryKey'), - operationType: auditEntity.get('operationType'), - executionResult: auditEntity.get('executionResult'), - objectType: auditEntity.get('objectType.name'), - changesCount: auditEntity.get('auditFields.length'), - name: auditEntity.get('auditFields').shiftObject().get('newValue'), - email: auditEntity.get('auditFields').shiftObject().get('newValue'), - }, { - objectPrimaryKey: id, - operationType: 'UPDATE', - executionResult: 'Не выполнено', - objectType: 'ember-flexberry-dummy-application-user', - changesCount: 4, - name: 'SuperMan', - email: 'super.man@example.com', - }, 'But we remember him.'); + return syncer.syncUp().then((result) => { + assert.equal(result, 2, 'Two operations were executed.'); + let builder = new Builder(store, 'ember-flexberry-dummy-application-user') + .selectByProjection('ApplicationUserE') + .byId(user.get('id')); + return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { + assert.notOk(onlineRecord, 'SuperMan is gone.'); + }); + }); + })); + }); + })).finally(done); + }); + }); + + test('sync without data to sync', function(assert) { + runTest(App, 1, assert, (store, syncer, done) => { + syncer.get('auditEnabled', false); + store.get('offlineGlobals').setOnlineAvailable(true); + return syncer.syncUp().then((result) => { + assert.equal(result, undefined, 'No operation was executed and promise was resolved.'); + }).finally(done);; + }); + }); + + skip('sync up with server error', function(assert) { + runTest(App, 2, assert, (store, syncer, done) => { + // Not cast value and throw error. + store.modelFor('ember-flexberry-dummy-application-user').reopen({ + vip: DS.attr('string'), + }); + + store.get('offlineGlobals').setOnlineAvailable(false); + return store.createRecord('ember-flexberry-dummy-application-user', { + name: 'SuperMan', + eMail: 'super.man@example.com', + vip: 'invalid', + }).save().then((user) => { + store.get('offlineGlobals').setOnlineAvailable(true); + return syncer.syncUp().catch((rejectedJob) => { + assert.equal(rejectedJob.get('executionResult'), 'Ошибка', 'Job not executed.'); + let builder = new Builder(store, 'ember-flexberry-dummy-application-user') + .selectByProjection('ApplicationUserE') + .byId(user.get('id')); + return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { + assert.notOk(onlineRecord, 'SuperMan is not there.'); + }); + }); + }).finally(done); + }); + }); + + skip('sync up with not found record', function(assert) { + runTest(App, 3, assert, (store, syncer, done) => { + store.createRecord('ember-flexberry-dummy-application-user', { + name: 'Man', + eMail: 'man@example.com', + }).save().then((user) => { + let id = user.get('id'); + return syncer.syncDown(user).then(() => { + store.get('offlineGlobals').setOnlineAvailable(false); + let builder = new Builder(store, 'ember-flexberry-dummy-application-user') + .selectByProjection('ApplicationUserE') + .byId(id); + return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((offlineRecord) => { + offlineRecord.set('name', 'SuperMan'); + offlineRecord.set('eMail', 'super.man@example.com'); + return offlineRecord.save().then(() => { + store.get('offlineGlobals').setOnlineAvailable(true); + let builder = new Builder(store, 'ember-flexberry-dummy-application-user') + .selectByProjection('ApplicationUserE') + .byId(id); + return store.queryRecord('ember-flexberry-dummy-application-user', builder.build()).then((onlineRecord) => { + assert.notEqual(onlineRecord.get('name'), 'SuperMan', `He was still an ordinary person.`); + return onlineRecord.destroyRecord().then(() => { + let options = { continueOnError: true }; + return syncer.syncUp(null, options).then((result) => { + assert.equal(result, 0, 'He never managed to become a SuperMan.'); + let query = new Builder(store, 'i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity') + .select('id,objectPrimaryKey,operationType,executionResult,objectType,auditFields') + .where('objectPrimaryKey', 'eq', id).build(); + return store.queryRecord(query.modelName, query).then((auditEntity) => { + assert.deepEqual({ + objectPrimaryKey: auditEntity.get('objectPrimaryKey'), + operationType: auditEntity.get('operationType'), + executionResult: auditEntity.get('executionResult'), + objectType: auditEntity.get('objectType.name'), + changesCount: auditEntity.get('auditFields.length'), + name: auditEntity.get('auditFields').shiftObject().get('newValue'), + email: auditEntity.get('auditFields').shiftObject().get('newValue'), + }, { + objectPrimaryKey: id, + operationType: 'UPDATE', + executionResult: 'Не выполнено', + objectType: 'ember-flexberry-dummy-application-user', + changesCount: 4, + name: 'SuperMan', + email: 'super.man@example.com', + }, 'But we remember him.'); + }); }); }); }); }); }); }); - }); - }).finally(done); + }).finally(done); + }); }); }); } diff --git a/tests/unit/adapters/odata-test.js b/tests/unit/adapters/odata-test.js index 138cd950..db11bccc 100644 --- a/tests/unit/adapters/odata-test.js +++ b/tests/unit/adapters/odata-test.js @@ -1,12 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('adapter:odata', 'Unit | Adapter | odata', { - // Specify the other units that are required for this test. - // needs: ['serializer:foo'] -}); +module('Unit | Adapter | odata', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function(assert) { - let adapter = this.subject(); - assert.ok(adapter); + test('it exists', function(assert) { + let adapter = this.owner.lookup('adapter:odata'); + assert.ok(adapter); + }); }); diff --git a/tests/unit/adapters/offline-test.js b/tests/unit/adapters/offline-test.js index 2fa02057..4819f571 100644 --- a/tests/unit/adapters/offline-test.js +++ b/tests/unit/adapters/offline-test.js @@ -1,15 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('adapter:offline', 'Unit | Adapter | offline', { - needs: [ - 'service:dexie', - ], -}); +module('Unit | Adapter | offline', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function(assert) { - let adapter = this.subject({ - databaseName: 'test' + test('it exists', function(assert) { + let adapter = this.owner.lookup('adapter:offline'); + assert.ok(adapter); }); - assert.ok(adapter); -}); +}); \ No newline at end of file diff --git a/tests/unit/initializers/local-store-test.js b/tests/unit/initializers/local-store-test.js index 246075a9..aadce650 100644 --- a/tests/unit/initializers/local-store-test.js +++ b/tests/unit/initializers/local-store-test.js @@ -5,19 +5,18 @@ import { module, test } from 'qunit'; let application; -module('Unit | Initializer | local store', { - beforeEach() { +module('Unit | Initializer | local store', function(hooks) { + hooks.beforeEach(function() { run(function() { application = Application.create(); application.deferReadiness(); }); - } -}); + }); -// Replace this with your real tests. -test('it works', function(assert) { - LocalStoreInitializer.initialize(application); + test('it works', function(assert) { + LocalStoreInitializer.initialize(application); - // you would normally confirm the results of the initializer here - assert.ok(true); -}); + // you would normally confirm the results of the initializer here + assert.ok(true); + }); +}); \ No newline at end of file diff --git a/tests/unit/initializers/offline-globals-test.js b/tests/unit/initializers/offline-globals-test.js index e77cc410..6a56782c 100644 --- a/tests/unit/initializers/offline-globals-test.js +++ b/tests/unit/initializers/offline-globals-test.js @@ -5,19 +5,18 @@ import { module, test } from 'qunit'; let application; -module('Unit | Initializer | offline globals', { - beforeEach() { +module('Unit | Initializer | offline globals', function(hooks) { + hooks.beforeEach(function() { run(function() { application = Application.create(); application.deferReadiness(); }); - } -}); + }); -// Replace this with your real tests. -test('it works', function(assert) { - OfflineGlobalsInitializer.initialize(application); + test('it works', function(assert) { + OfflineGlobalsInitializer.initialize(application); - // you would normally confirm the results of the initializer here - assert.ok(true); -}); + // you would normally confirm the results of the initializer here + assert.ok(true); + }); +}); \ No newline at end of file diff --git a/tests/unit/instance-initializers/set-singletons-test.js b/tests/unit/instance-initializers/set-singletons-test.js index ace41ef2..afd77060 100644 --- a/tests/unit/instance-initializers/set-singletons-test.js +++ b/tests/unit/instance-initializers/set-singletons-test.js @@ -4,23 +4,22 @@ import { initialize } from 'dummy/instance-initializers/set-singletons'; import { module, test } from 'qunit'; import destroyApp from '../../helpers/destroy-app'; -module('Unit | Instance Initializer | set singletons', { - beforeEach: function() { +module('Unit | Instance Initializer | set singletons', function(hooks) { + hooks.beforeEach(function() { run(() => { this.application = Application.create(); this.appInstance = this.application.buildInstance(); }); - }, - afterEach: function() { + }); + hooks.afterEach(function() { run(this.appInstance, 'destroy'); destroyApp(this.application); - } -}); + }); -// Replace this with your real tests. -test('it works', function(assert) { - initialize(this.appInstance); + test('it works', function(assert) { + initialize(this.appInstance); - // you would normally confirm the results of the initializer here - assert.ok(true); + // you would normally confirm the results of the initializer here + assert.ok(true); + }); }); diff --git a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-test.js b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-test.js index d3a4a03e..96a486a2 100644 --- a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-test.js +++ b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-test.js @@ -1,14 +1,11 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity', 'Unit | Model | audit-entity', { - needs: [ - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-security-agent', - ], -}); +module('Unit | Model | audit-entity', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let model = this.subject(); - assert.ok(!!model); + test('it exists', function(assert) { + let model = this.owner.lookup('service:store').modelFor('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity'); + assert.ok(!!model); + }); }); diff --git a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-test.js b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-test.js index 0bc401fb..84f1a4a7 100644 --- a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-test.js +++ b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-test.js @@ -1,12 +1,11 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field', 'Unit | Model | audit-field', { - needs: [ - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity', - ], -}); +module('Unit | Model | audit-field', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let model = this.subject(); - assert.ok(!!model); + test('it exists', function(assert) { + let model = this.owner.lookup('service:store').modelFor('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field'); + assert.ok(!!model); + }); }); diff --git a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-test.js b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-test.js index 402dd467..255b360f 100644 --- a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-test.js +++ b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-test.js @@ -1,11 +1,11 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type', 'Unit | Model | object-type', { - needs: [ - ], -}); +module('Unit | Model | object-type', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let model = this.subject(); - assert.ok(!!model); + test('it exists', function(assert) { + let model = this.owner.lookup('service:store').modelFor('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type'); + assert.ok(!!model); + }); }); diff --git a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-test.js b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-test.js index 4c37e177..8d432acc 100644 --- a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-test.js +++ b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-test.js @@ -1,11 +1,11 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-security-agent', 'Unit | Model | agent', { - needs: [ - ], -}); +module('Unit | Model | agent', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let model = this.subject(); - assert.ok(!!model); + test('it exists', function(assert) { + let model = this.owner.lookup('service:store').modelFor('i-c-s-soft-s-t-o-r-m-n-e-t-security-agent'); + assert.ok(!!model); + }); }); diff --git a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group-test.js b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group-test.js index db2f8f8d..aed85eab 100644 --- a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group-test.js +++ b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group-test.js @@ -1,13 +1,11 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group', 'Unit | Model | link-group', { - needs: [ - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-security-agent', - 'service:syncer', - ], -}); +module('Unit | Model | link-group', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let model = this.subject(); - assert.ok(!!model); + test('it exists', function(assert) { + let model = this.owner.lookup('service:store').modelFor('i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group'); + assert.ok(!!model); + }); }); diff --git a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-session-test.js b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-session-test.js index 51426303..dc4a1ab8 100644 --- a/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-session-test.js +++ b/tests/unit/models/i-c-s-soft-s-t-o-r-m-n-e-t-security-session-test.js @@ -1,12 +1,11 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-security-session', 'Unit | Model | session', { - needs: [ - 'service:syncer', - ], -}); +module('Unit | Model | session', function(hooks) { + setupTest(hooks); -test('it exists', function(assert) { - let model = this.subject(); - assert.ok(!!model); + test('it exists', function(assert) { + let model = this.owner.lookup('service:store').modelFor('i-c-s-soft-s-t-o-r-m-n-e-t-security-session'); + assert.ok(!!model); + }); }); diff --git a/tests/unit/models/model-test.js b/tests/unit/models/model-test.js index 8d85db03..30d012f2 100644 --- a/tests/unit/models/model-test.js +++ b/tests/unit/models/model-test.js @@ -1,156 +1,140 @@ import { run } from '@ember/runloop'; -import { moduleForModel, test } from 'ember-qunit'; - -moduleForModel('model', 'Unit | Model | model', { - needs: [ - 'model:ember-flexberry-dummy-suggestion', - 'model:ember-flexberry-dummy-suggestion-type', - 'model:ember-flexberry-dummy-application-user', - 'model:ember-flexberry-dummy-vote', - 'model:ember-flexberry-dummy-suggestion-file', - 'model:ember-flexberry-dummy-comment', - 'model:ember-flexberry-dummy-comment-vote', - 'model:ember-flexberry-dummy-localized-suggestion-type', - 'service:syncer', - ], -}); - -test('it exists', function(assert) { - let model = this.subject(); - - // let store = this.store(); - assert.ok(!!model); -}); - -test('rollback hasMany relationships', function(assert) { - run(() => { - let store = this.store(); - - let suggestion = store.createRecord('ember-flexberry-dummy-suggestion'); - - let vote1 = store.createRecord('ember-flexberry-dummy-vote'); - let vote2 = store.createRecord('ember-flexberry-dummy-vote'); - - let comment1 = store.createRecord('ember-flexberry-dummy-comment'); - let comment2 = store.createRecord('ember-flexberry-dummy-comment'); - - //Change `hasMany` relationships. - suggestion.set('userVotes', [vote1, vote2]); - suggestion.set('comments', [comment1, comment2]); - - //Diff `hasMany` relationships. - assert.deepEqual(suggestion.changedHasMany(), { - userVotes: [[], [vote1, vote2]], - comments: [[], [comment1, comment2]], - }, `Results 'changedHasMany' function as expected.`); - - //Rollback `hasMany` for only `userVotes` relationship. - suggestion.rollbackHasMany('userVotes'); - assert.deepEqual({ - userVotes: suggestion.get('userVotes').map(record => record), - comments: suggestion.get('comments').map(record => record), - }, { - userVotes: [], - comments: [comment1, comment2], - }, `Results 'rollbackHasMany' function with 'forOnlyKey' specified as expected.`); - - //Rollback all `hasMany` relationships. - suggestion.rollbackHasMany(); - assert.deepEqual({ - userVotes: suggestion.get('userVotes').map(record => record), - comments: suggestion.get('comments').map(record => record), - }, { - userVotes: [], - comments: [], - }, `Results 'rollbackHasMany' function without 'forOnlyKey' specified as expected.`); +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Model | model', function(hooks) { + setupTest(hooks); + + test('rollback hasMany relationships', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + + let suggestion = store.createRecord('ember-flexberry-dummy-suggestion'); + + let vote1 = store.createRecord('ember-flexberry-dummy-vote'); + let vote2 = store.createRecord('ember-flexberry-dummy-vote'); + + let comment1 = store.createRecord('ember-flexberry-dummy-comment'); + let comment2 = store.createRecord('ember-flexberry-dummy-comment'); + + //Change `hasMany` relationships. + suggestion.set('userVotes', [vote1, vote2]); + suggestion.set('comments', [comment1, comment2]); + + //Diff `hasMany` relationships. + assert.deepEqual(suggestion.changedHasMany(), { + userVotes: [[], [vote1, vote2]], + comments: [[], [comment1, comment2]], + }, `Results 'changedHasMany' function as expected.`); + + //Rollback `hasMany` for only `userVotes` relationship. + suggestion.rollbackHasMany('userVotes'); + assert.deepEqual({ + userVotes: suggestion.get('userVotes').map(record => record), + comments: suggestion.get('comments').map(record => record), + }, { + userVotes: [], + comments: [comment1, comment2], + }, `Results 'rollbackHasMany' function with 'forOnlyKey' specified as expected.`); + + //Rollback all `hasMany` relationships. + suggestion.rollbackHasMany(); + assert.deepEqual({ + userVotes: suggestion.get('userVotes').map(record => record), + comments: suggestion.get('comments').map(record => record), + }, { + userVotes: [], + comments: [], + }, `Results 'rollbackHasMany' function without 'forOnlyKey' specified as expected.`); + }); }); -}); -test('rollback belongsTo relationships', function(assert) { - run(() => { - let store = this.store(); + test('rollback belongsTo relationships', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + + let type1 = store.createRecord('ember-flexberry-dummy-suggestion-type'); + let type2 = store.createRecord('ember-flexberry-dummy-suggestion-type'); + + let user1 = store.createRecord('ember-flexberry-dummy-application-user'); + let user2 = store.createRecord('ember-flexberry-dummy-application-user'); + + let suggestion = store.createRecord('ember-flexberry-dummy-suggestion', { + type: type1, + author: user1, + editor1: user1, + }); + + //Instead of save on server. + suggestion.didLoad(); + + //Change `belongsTo` relationships. + suggestion.set('type', type2); + suggestion.set('author', user2); + suggestion.set('editor1', user2); + + //Diff `belongsTo` relationships. + assert.deepEqual(suggestion.changedBelongsTo(), { + type: [type1, type2], + author: [user1, user2], + editor1: [user1, user2], + }, `Results 'changedBelongsTo' function as expected.`); + + //Rollback `belongsTo` for only `type` relationship. + suggestion.rollbackBelongsTo('type'); + assert.deepEqual({ + type: suggestion.get('type'), + author: suggestion.get('author'), + editor1: suggestion.get('editor1'), + }, { + type: type1, + author: user2, + editor1: user2, + }, `Results 'rollbackBelongsTo' function with 'forOnlyKey' specified as expected.`); + + //Rollback all `belongsTo` relationships. + suggestion.rollbackBelongsTo(); + assert.deepEqual({ + type: suggestion.get('type'), + author: suggestion.get('author'), + editor1: suggestion.get('editor1'), + }, { + type: type1, + author: user1, + editor1: user1, + }, `Results 'rollbackBelongsTo' function without 'forOnlyKey' specified as expected.`); + }); + }); - let type1 = store.createRecord('ember-flexberry-dummy-suggestion-type'); - let type2 = store.createRecord('ember-flexberry-dummy-suggestion-type'); + test('changedBelongsTo after saving the created model', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); - let user1 = store.createRecord('ember-flexberry-dummy-application-user'); - let user2 = store.createRecord('ember-flexberry-dummy-application-user'); + let type1 = store.createRecord('ember-flexberry-dummy-suggestion-type'); - let suggestion = store.createRecord('ember-flexberry-dummy-suggestion', { - type: type1, - author: user1, - editor1: user1, - }); + let user1 = store.createRecord('ember-flexberry-dummy-application-user'); - //Instead of save on server. - suggestion.didLoad(); - - //Change `belongsTo` relationships. - suggestion.set('type', type2); - suggestion.set('author', user2); - suggestion.set('editor1', user2); - - //Diff `belongsTo` relationships. - assert.deepEqual(suggestion.changedBelongsTo(), { - type: [type1, type2], - author: [user1, user2], - editor1: [user1, user2], - }, `Results 'changedBelongsTo' function as expected.`); - - //Rollback `belongsTo` for only `type` relationship. - suggestion.rollbackBelongsTo('type'); - assert.deepEqual({ - type: suggestion.get('type'), - author: suggestion.get('author'), - editor1: suggestion.get('editor1'), - }, { - type: type1, - author: user2, - editor1: user2, - }, `Results 'rollbackBelongsTo' function with 'forOnlyKey' specified as expected.`); - - //Rollback all `belongsTo` relationships. - suggestion.rollbackBelongsTo(); - assert.deepEqual({ - type: suggestion.get('type'), - author: suggestion.get('author'), - editor1: suggestion.get('editor1'), - }, { - type: type1, - author: user1, - editor1: user1, - }, `Results 'rollbackBelongsTo' function without 'forOnlyKey' specified as expected.`); - }); -}); - -test('changedBelongsTo after saving the created model', function(assert) { - run(() => { - let store = this.store(); + let suggestion = store.createRecord('ember-flexberry-dummy-suggestion', { + type: type1, + author: user1, + editor1: user1, + }); - let type1 = store.createRecord('ember-flexberry-dummy-suggestion-type'); + //Diff `belongsTo` relationships. + assert.ok(suggestion.hasChangedBelongsTo()); + assert.deepEqual(suggestion.changedBelongsTo(), { + type: [null, type1], + author: [null, user1], + editor1: [null, user1], + }, `Results 'changedBelongsTo' function as expected.`); - let user1 = store.createRecord('ember-flexberry-dummy-application-user'); + //Instead of save on server. + suggestion.didCreate(); - let suggestion = store.createRecord('ember-flexberry-dummy-suggestion', { - type: type1, - author: user1, - editor1: user1, + //Diff `belongsTo` relationships. + assert.notOk(suggestion.hasChangedBelongsTo()); + assert.deepEqual(suggestion.changedBelongsTo(), { + }, `Results 'changedBelongsTo' function as expected.`); }); - - //Diff `belongsTo` relationships. - assert.ok(suggestion.hasChangedBelongsTo()); - assert.deepEqual(suggestion.changedBelongsTo(), { - type: [null, type1], - author: [null, user1], - editor1: [null, user1], - }, `Results 'changedBelongsTo' function as expected.`); - - //Instead of save on server. - suggestion.didCreate(); - - //Diff `belongsTo` relationships. - assert.notOk(suggestion.hasChangedBelongsTo()); - assert.deepEqual(suggestion.changedBelongsTo(), { - }, `Results 'changedBelongsTo' function as expected.`); }); }); diff --git a/tests/unit/models/model-without-validation-test.js b/tests/unit/models/model-without-validation-test.js index dac45101..5ac55c90 100644 --- a/tests/unit/models/model-without-validation-test.js +++ b/tests/unit/models/model-without-validation-test.js @@ -1,162 +1,146 @@ import { run } from '@ember/runloop'; -import { moduleForModel, test } from 'ember-qunit'; - -moduleForModel('model-without-validation', 'Unit | Model | model without validation', { - needs: [ - 'model:ember-flexberry-dummy-suggestion', - 'model:ember-flexberry-dummy-suggestion-type', - 'model:ember-flexberry-dummy-application-user', - 'model:ember-flexberry-dummy-vote', - 'model:ember-flexberry-dummy-suggestion-file', - 'model:ember-flexberry-dummy-comment', - 'model:ember-flexberry-dummy-comment-vote', - 'model:ember-flexberry-dummy-localized-suggestion-type', - 'service:syncer', - ], -}); - -test('it exists', function(assert) { - let model = this.subject(); - - // let store = this.store(); - assert.ok(!!model); -}); - -test('rollback hasMany relationships', function(assert) { - run(() => { - let store = this.store(); - - let suggestion = store.createRecord('ember-flexberry-dummy-suggestion'); - - let vote1 = store.createRecord('ember-flexberry-dummy-vote'); - let vote2 = store.createRecord('ember-flexberry-dummy-vote'); - - let comment1 = store.createRecord('ember-flexberry-dummy-comment'); - let comment2 = store.createRecord('ember-flexberry-dummy-comment'); - - assert.notOk(suggestion.hasChangedHasMany()); - - //Change `hasMany` relationships. - suggestion.set('userVotes', [vote1, vote2]); - suggestion.set('comments', [comment1, comment2]); - - assert.ok(suggestion.hasChangedHasMany()); - - //Diff `hasMany` relationships. - assert.deepEqual(suggestion.changedHasMany(), { - userVotes: [[], [vote1, vote2]], - comments: [[], [comment1, comment2]], - }, `Results 'changedHasMany' function as expected.`); - - //Rollback `hasMany` for only `userVotes` relationship. - suggestion.rollbackHasMany('userVotes'); - assert.ok(suggestion.hasChangedHasMany()); - assert.deepEqual({ - userVotes: suggestion.get('userVotes').map(record => record), - comments: suggestion.get('comments').map(record => record), - }, { - userVotes: [], - comments: [comment1, comment2], - }, `Results 'rollbackHasMany' function with 'forOnlyKey' specified as expected.`); - - //Rollback all `hasMany` relationships. - suggestion.rollbackHasMany(); - assert.notOk(suggestion.hasChangedHasMany()); - assert.deepEqual({ - userVotes: suggestion.get('userVotes').map(record => record), - comments: suggestion.get('comments').map(record => record), - }, { - userVotes: [], - comments: [], - }, `Results 'rollbackHasMany' function without 'forOnlyKey' specified as expected.`); +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Model | model without validation', function(hooks) { + setupTest(hooks); + + test('rollback hasMany relationships', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + + let suggestion = store.createRecord('ember-flexberry-dummy-suggestion'); + + let vote1 = store.createRecord('ember-flexberry-dummy-vote'); + let vote2 = store.createRecord('ember-flexberry-dummy-vote'); + + let comment1 = store.createRecord('ember-flexberry-dummy-comment'); + let comment2 = store.createRecord('ember-flexberry-dummy-comment'); + + assert.notOk(suggestion.hasChangedHasMany()); + + //Change `hasMany` relationships. + suggestion.set('userVotes', [vote1, vote2]); + suggestion.set('comments', [comment1, comment2]); + + assert.ok(suggestion.hasChangedHasMany()); + + //Diff `hasMany` relationships. + assert.deepEqual(suggestion.changedHasMany(), { + userVotes: [[], [vote1, vote2]], + comments: [[], [comment1, comment2]], + }, `Results 'changedHasMany' function as expected.`); + + //Rollback `hasMany` for only `userVotes` relationship. + suggestion.rollbackHasMany('userVotes'); + assert.ok(suggestion.hasChangedHasMany()); + assert.deepEqual({ + userVotes: suggestion.get('userVotes').map(record => record), + comments: suggestion.get('comments').map(record => record), + }, { + userVotes: [], + comments: [comment1, comment2], + }, `Results 'rollbackHasMany' function with 'forOnlyKey' specified as expected.`); + + //Rollback all `hasMany` relationships. + suggestion.rollbackHasMany(); + assert.notOk(suggestion.hasChangedHasMany()); + assert.deepEqual({ + userVotes: suggestion.get('userVotes').map(record => record), + comments: suggestion.get('comments').map(record => record), + }, { + userVotes: [], + comments: [], + }, `Results 'rollbackHasMany' function without 'forOnlyKey' specified as expected.`); + }); }); -}); -test('rollback belongsTo relationships', function(assert) { - run(() => { - let store = this.store(); + test('rollback belongsTo relationships', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + + let type1 = store.createRecord('ember-flexberry-dummy-suggestion-type'); + let type2 = store.createRecord('ember-flexberry-dummy-suggestion-type'); + + let user1 = store.createRecord('ember-flexberry-dummy-application-user'); + let user2 = store.createRecord('ember-flexberry-dummy-application-user'); + + let suggestion = store.createRecord('ember-flexberry-dummy-suggestion', { + type: type1, + author: user1, + editor1: user1, + }); + + //Instead of save on server. + suggestion.didLoad(); + + //Change `belongsTo` relationships. + suggestion.set('type', type2); + suggestion.set('author', user2); + suggestion.set('editor1', user2); + + //Diff `belongsTo` relationships. + assert.deepEqual(suggestion.changedBelongsTo(), { + type: [type1, type2], + author: [user1, user2], + editor1: [user1, user2], + }, `Results 'changedBelongsTo' function as expected.`); + + //Rollback `belongsTo` for only `type` relationship. + suggestion.rollbackBelongsTo('type'); + assert.deepEqual({ + type: suggestion.get('type'), + author: suggestion.get('author'), + editor1: suggestion.get('editor1'), + }, { + type: type1, + author: user2, + editor1: user2, + }, `Results 'rollbackBelongsTo' function with 'forOnlyKey' specified as expected.`); + + //Rollback all `belongsTo` relationships. + suggestion.rollbackBelongsTo(); + assert.deepEqual({ + type: suggestion.get('type'), + author: suggestion.get('author'), + editor1: suggestion.get('editor1'), + }, { + type: type1, + author: user1, + editor1: user1, + }, `Results 'rollbackBelongsTo' function without 'forOnlyKey' specified as expected.`); + }); + }); - let type1 = store.createRecord('ember-flexberry-dummy-suggestion-type'); - let type2 = store.createRecord('ember-flexberry-dummy-suggestion-type'); + test('changedBelongsTo after saving the created model', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); - let user1 = store.createRecord('ember-flexberry-dummy-application-user'); - let user2 = store.createRecord('ember-flexberry-dummy-application-user'); + let type1 = store.createRecord('ember-flexberry-dummy-suggestion-type'); - let suggestion = store.createRecord('ember-flexberry-dummy-suggestion', { - type: type1, - author: user1, - editor1: user1, - }); + let user1 = store.createRecord('ember-flexberry-dummy-application-user'); - //Instead of save on server. - suggestion.didLoad(); - - //Change `belongsTo` relationships. - suggestion.set('type', type2); - suggestion.set('author', user2); - suggestion.set('editor1', user2); - - //Diff `belongsTo` relationships. - assert.deepEqual(suggestion.changedBelongsTo(), { - type: [type1, type2], - author: [user1, user2], - editor1: [user1, user2], - }, `Results 'changedBelongsTo' function as expected.`); - - //Rollback `belongsTo` for only `type` relationship. - suggestion.rollbackBelongsTo('type'); - assert.deepEqual({ - type: suggestion.get('type'), - author: suggestion.get('author'), - editor1: suggestion.get('editor1'), - }, { - type: type1, - author: user2, - editor1: user2, - }, `Results 'rollbackBelongsTo' function with 'forOnlyKey' specified as expected.`); - - //Rollback all `belongsTo` relationships. - suggestion.rollbackBelongsTo(); - assert.deepEqual({ - type: suggestion.get('type'), - author: suggestion.get('author'), - editor1: suggestion.get('editor1'), - }, { - type: type1, - author: user1, - editor1: user1, - }, `Results 'rollbackBelongsTo' function without 'forOnlyKey' specified as expected.`); - }); -}); - -test('changedBelongsTo after saving the created model', function(assert) { - run(() => { - let store = this.store(); + let suggestion = store.createRecord('ember-flexberry-dummy-suggestion', { + type: type1, + author: user1, + editor1: user1, + }); - let type1 = store.createRecord('ember-flexberry-dummy-suggestion-type'); + //Diff `belongsTo` relationships. + assert.ok(suggestion.hasChangedBelongsTo()); + assert.deepEqual(suggestion.changedBelongsTo(), { + type: [null, type1], + author: [null, user1], + editor1: [null, user1], + }, `Results 'changedBelongsTo' function as expected.`); - let user1 = store.createRecord('ember-flexberry-dummy-application-user'); + //Instead of save on server. + suggestion.didCreate(); - let suggestion = store.createRecord('ember-flexberry-dummy-suggestion', { - type: type1, - author: user1, - editor1: user1, + //Diff `belongsTo` relationships. + assert.notOk(suggestion.hasChangedBelongsTo()); + assert.deepEqual(suggestion.changedBelongsTo(), { + }, `Results 'changedBelongsTo' function as expected.`); }); - - //Diff `belongsTo` relationships. - assert.ok(suggestion.hasChangedBelongsTo()); - assert.deepEqual(suggestion.changedBelongsTo(), { - type: [null, type1], - author: [null, user1], - editor1: [null, user1], - }, `Results 'changedBelongsTo' function as expected.`); - - //Instead of save on server. - suggestion.didCreate(); - - //Diff `belongsTo` relationships. - assert.notOk(suggestion.hasChangedBelongsTo()); - assert.deepEqual(suggestion.changedBelongsTo(), { - }, `Results 'changedBelongsTo' function as expected.`); }); }); diff --git a/tests/unit/models/offline-model-test.js b/tests/unit/models/offline-model-test.js index 5912daf5..04c4a635 100644 --- a/tests/unit/models/offline-model-test.js +++ b/tests/unit/models/offline-model-test.js @@ -1,44 +1,23 @@ -import { run } from '@ember/runloop'; import { isNone } from '@ember/utils'; import { get } from '@ember/object'; -import { moduleForModel, test } from 'ember-qunit'; - -import startApp from '../../helpers/start-app'; - -let App; - -moduleForModel('offline-model', 'Unit | Model | offline model', { - needs: [ - 'service:syncer', - ], - - beforeEach() { - App = startApp(); - }, - - afterEach() { - run(App, 'destroy'); - } -}); - -test('it exists', function(assert) { - let model = this.subject(); - - // let store = this.store(); - assert.ok(!!model); -}); - -test('projections have addintional metadata', function(assert) { - let store = App.__container__.lookup('service:store'); - const EmployeeOffline = store.modelFor('employee-offline'); - const projectionName = 'EmployeeTestProjection'; - let projection = get(EmployeeOffline, 'projections')[projectionName]; - - assert.ok(!isNone(EmployeeOffline.projections), 'there is no projections in model "employee-offline"'); - assert.ok(!isNone(projection), 'projection "EmployeeTestProjection" is absent'); - assert.ok(!isNone(projection.attributes.createTime), '"EmployeeTestProjection.createTime" metadata property is absent'); - assert.ok(!isNone(projection.attributes.employee1.attributes.createTime), - '"EmployeeTestProjection.employee1.createTime" metadata property is absent (for belongsTo relationship)'); - assert.ok(!isNone(projection.attributes.tmpChildren.attributes.createTime), - '"EmployeeTestProjection.tmpChildren.createTime" metadata property is absent (for hasMany relationship)'); +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Model | offline model', function(hooks) { + setupTest(hooks); + + test('projections have addintional metadata', function(assert) { + let store = this.owner.lookup('service:store'); + const EmployeeOffline = store.modelFor('employee-offline'); + const projectionName = 'EmployeeTestProjection'; + let projection = get(EmployeeOffline, 'projections')[projectionName]; + + assert.ok(!isNone(EmployeeOffline.projections), 'there is no projections in model "employee-offline"'); + assert.ok(!isNone(projection), 'projection "EmployeeTestProjection" is absent'); + assert.ok(!isNone(projection.attributes.createTime), '"EmployeeTestProjection.createTime" metadata property is absent'); + assert.ok(!isNone(projection.attributes.employee1.attributes.createTime), + '"EmployeeTestProjection.employee1.createTime" metadata property is absent (for belongsTo relationship)'); + assert.ok(!isNone(projection.attributes.tmpChildren.attributes.createTime), + '"EmployeeTestProjection.tmpChildren.createTime" metadata property is absent (for hasMany relationship)'); + }); }); diff --git a/tests/unit/odata/odata-ajax-requests-test.js b/tests/unit/odata/odata-ajax-requests-test.js index 8b49e2b8..2c443238 100644 --- a/tests/unit/odata/odata-ajax-requests-test.js +++ b/tests/unit/odata/odata-ajax-requests-test.js @@ -1,6 +1,6 @@ /*global wait $*/ import { run } from '@ember/runloop'; -import { moduleFor, skip } from 'ember-qunit'; +import { module, skip } from 'qunit'; import DS from 'ember-data'; import OdataAdapter from 'ember-flexberry-data/adapters/odata'; @@ -13,101 +13,97 @@ const testStore = DS.Store.extend({ } }); -moduleFor('adapter:odata', 'Unit | Adapter | odata | ajax', { - // Specify the other units that are required for this test. - // needs: ['serializer:foo'] +module('Unit | Adapter | odata | ajax', function(hooks) { + skip('ajax functions tests', function(assert) { + let done = assert.async(); + const app = startApp(); + app.register('service:test-store', testStore); + const adapter = OdataAdapter.create(app.__container__.ownerInjection()); + const store = app.__container__.lookup('service:test-store'); -}); - -skip('ajax functions tests', function(assert) { - let done = assert.async(); - const app = startApp(); - app.register('service:test-store', testStore); - const adapter = OdataAdapter.create(app.__container__.ownerInjection()); - const store = app.__container__.lookup('service:test-store'); - - run(() => { - $.mockjax({ - url: '/test-models/test', - responseText: { ab: 'cd' } - }); - return adapter.callAction('test', { abcd: 'def' }, '/test-models') - .then((msg) => { - assert.equal(msg.ab, 'cd', 'getting POST response'); - }) - - .then(() => { - $.mockjax({ - url: '/test-models/test(abcd=\'def\')', - type: 'GET', - responseText: { ab: 'cd' } - }); - return adapter.callFunction('test', { abcd: 'def' }, '/test-models') - .then((msg) => { - assert.equal(msg.ab, 'cd', 'getting GET response'); - }); - }) - .then(() => { + run(() => { $.mockjax({ url: '/test-models/test', responseText: { ab: 'cd' } }); - return adapter.callAction( - 'test', { abcd: 'def' }, - '/test-models', - null, - (msg) => { - assert.equal(msg.ab + ' success', 'cd success', 'successCallback works'); - return msg.ab + ' success'; - }, - (msg) => { - assert.notEqual(msg.ab, 'cd', 'failCallback works'); - return msg.ab + ' fail'; - }, - (msg) => { - assert.equal(msg.ab + ' always', 'cd always', 'alwaysCallback works'); - return msg.ab + ' always'; - }) + return adapter.callAction('test', { abcd: 'def' }, '/test-models') .then((msg) => { - assert.equal(msg.ab, 'cd', 'getting GET response'); - }); - }) + assert.equal(msg.ab, 'cd', 'getting POST response'); + }) - .then(() => { - $.mockjax({ - url: '/test-models/test-odata-function()', - type: 'GET', - responseText: { value: [{ __PrimaryKey: '1', Name: 'Russia' }, { __PrimaryKey: '2', Name: 'Kongo' }] } - }); - return adapter.callEmberOdataFunction('test-odata-function', { }, '/test-models', null, store, 'country') - .then((msg) => { - assert.equal(msg.length, 2, 'correct record number'); - msg.forEach(record => { - assert.equal(record.constructor.modelName, 'country', 'is instance of correct model'); + .then(() => { + $.mockjax({ + url: '/test-models/test(abcd=\'def\')', + type: 'GET', + responseText: { ab: 'cd' } }); - }); - }) + return adapter.callFunction('test', { abcd: 'def' }, '/test-models') + .then((msg) => { + assert.equal(msg.ab, 'cd', 'getting GET response'); + }); + }) + .then(() => { + $.mockjax({ + url: '/test-models/test', + responseText: { ab: 'cd' } + }); + return adapter.callAction( + 'test', { abcd: 'def' }, + '/test-models', + null, + (msg) => { + assert.equal(msg.ab + ' success', 'cd success', 'successCallback works'); + return msg.ab + ' success'; + }, + (msg) => { + assert.notEqual(msg.ab, 'cd', 'failCallback works'); + return msg.ab + ' fail'; + }, + (msg) => { + assert.equal(msg.ab + ' always', 'cd always', 'alwaysCallback works'); + return msg.ab + ' always'; + }) + .then((msg) => { + assert.equal(msg.ab, 'cd', 'getting GET response'); + }); + }) - .then(() => { - $.mockjax({ - url: '/test-models/test-odata-action()', - responseText: { value: [{ __PrimaryKey: '1', Name: 'Russia' }, { __PrimaryKey: '2', Name: 'Kongo' }] } - }); - return adapter.callEmberOdataFunction('test-odata-action', { }, '/test-models', null, store, 'country') - .then((msg) => { - assert.equal(msg.length, 2, 'correct record number'); - msg.forEach(record => { - assert.equal(record.constructor.modelName, 'country', 'is instance of correct model'); + .then(() => { + $.mockjax({ + url: '/test-models/test-odata-function()', + type: 'GET', + responseText: { value: [{ __PrimaryKey: '1', Name: 'Russia' }, { __PrimaryKey: '2', Name: 'Kongo' }] } }); - }); - }) + return adapter.callEmberOdataFunction('test-odata-function', { }, '/test-models', null, store, 'country') + .then((msg) => { + assert.equal(msg.length, 2, 'correct record number'); + msg.forEach(record => { + assert.equal(record.constructor.modelName, 'country', 'is instance of correct model'); + }); + }); + }) + + .then(() => { + $.mockjax({ + url: '/test-models/test-odata-action()', + responseText: { value: [{ __PrimaryKey: '1', Name: 'Russia' }, { __PrimaryKey: '2', Name: 'Kongo' }] } + }); + return adapter.callEmberOdataFunction('test-odata-action', { }, '/test-models', null, store, 'country') + .then((msg) => { + assert.equal(msg.length, 2, 'correct record number'); + msg.forEach(record => { + assert.equal(record.constructor.modelName, 'country', 'is instance of correct model'); + }); + }); + }) - .catch(e => { - // eslint-disable-next-line no-console - console.log(e, e.message); - assert.ok(false, e.message); - }) - .finally(done); + .catch(e => { + // eslint-disable-next-line no-console + console.log(e, e.message); + assert.ok(false, e.message); + }) + .finally(done); + }); + wait(); }); - wait(); }); diff --git a/tests/unit/odata/odata-void-request-test.js b/tests/unit/odata/odata-void-request-test.js index 2cbeebbb..1a8cc0a1 100644 --- a/tests/unit/odata/odata-void-request-test.js +++ b/tests/unit/odata/odata-void-request-test.js @@ -1,30 +1,26 @@ import Ember from 'ember'; -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; import OdataAdapter from 'ember-flexberry-data/adapters/odata'; import startApp from '../../helpers/start-app'; -moduleFor('adapter:odata', 'Unit | Adapter | odata | void request', { - // Specify the other units that are required for this test. - // needs: ['serializer:foo'] +module('Unit | Adapter | odata | void request', function(hooks) { + test('void functions test', function(assert) { + let done = assert.async(); + const app = startApp(); + const adapter = OdataAdapter.create(app.__container__.ownerInjection()); -}); - -test('void functions test', function(assert) { - let done = assert.async(); - const app = startApp(); - const adapter = OdataAdapter.create(app.__container__.ownerInjection()); - - Ember.run(() => { - return adapter.callAction('ExecuteVoidAction', { }, null) - .then((msg) => { - assert.equal(msg, undefined, "Method returned UNDEFINED as expected.") - }) - .catch(e => { - console.log(e, e.message); - assert.ok(false, e.message); - }) - .finally(done); + Ember.run(() => { + return adapter.callAction('ExecuteVoidAction', { }, null) + .then((msg) => { + assert.equal(msg, undefined, "Method returned UNDEFINED as expected.") + }) + .catch(e => { + console.log(e, e.message); + assert.ok(false, e.message); + }) + .finally(done); + }); + wait(); }); - wait(); }); diff --git a/tests/unit/offline/offline-CRUD-test.js b/tests/unit/offline/offline-CRUD-test.js index 106f6e00..e04c73f1 100644 --- a/tests/unit/offline/offline-CRUD-test.js +++ b/tests/unit/offline/offline-CRUD-test.js @@ -11,8 +11,8 @@ let AppOfflineCrudTest; let storeOfflineCrudTest; const dbNameOfflineCrudTest = 'TestDbOCT'; -module('offline-CRUD', { - beforeEach: function (assert) { +module('offline-CRUD', function(hooks) { + hooks.beforeEach(function (assert) { let done = assert.async(); run(function () { AppOfflineCrudTest = startApp(); @@ -105,163 +105,163 @@ module('offline-CRUD', { }).finally(done); }).catch(done); }); - }, + }); - afterEach: function () { + hooks.afterEach(function () { run(function () { let dexieService = AppOfflineCrudTest.__container__.lookup('service:dexie'); dexieService.close(dbNameOfflineCrudTest); destroyApp(AppOfflineCrudTest); }); - } -}); - -test('find record', function (assert) { - assert.expect(13); - let done1 = assert.async(); - run(function () { - storeOfflineCrudTest.findRecord('ember-flexberry-dummy-suggestion', 'fea5b275-cb9b-4584-ba04-26122bc8cbd3').then(function(records) { - assert.equal(get(records, 'address'), 'Street, 20', 'record address = Street, 20'); - assert.equal(get(records, 'text'), 'Loooong text', 'record text = Loooong text'); - assert.equal(get(records, 'votes'), 1, 'record votes = 1'); - assert.equal(get(records, 'moderated'), false, '1 record was found'); - }).finally(done1); - }); - let done2 = assert.async(); - run(function () { - storeOfflineCrudTest.findRecord('ember-flexberry-dummy-suggestion-type', 'de627522-47c3-428f-99be-fdac2e8f5618').then(function(records) { - assert.equal(get(records, 'name'), '123', '1 record was found'); - assert.equal(get(records, 'moderated'), false, '1 record was found'); - }).finally(done2); - }); - let done3 = assert.async(); - run(function () { - storeOfflineCrudTest.findRecord('ember-flexberry-dummy-application-user', '555a6d25-ac76-417c-bcc5-25bc260fc3ae').then(function(records) { - assert.equal(get(records, 'name'), 'Васиииилий', '1 record was found'); - assert.equal(get(records, 'eMail'), 'pupkin1@mail.ru', '1 record was found'); - assert.equal(get(records, 'activated'), true, '1 record was found'); - }).finally(done3); - }); - let done4 = assert.async(); - run(function () { - storeOfflineCrudTest.findRecord('ember-flexberry-dummy-vote', '8be0d89b-8cab-4b0b-b029-356c59809163').then(function(records) { - assert.equal(get(records, 'voteType'), 'Like', '1 record was found'); - }).finally(done4); - }); - let done5 = assert.async(); - run(function () { - storeOfflineCrudTest.findRecord('ember-flexberry-dummy-comment', '7e5d3b63-eb5e-446e-84da-26865f87c1c5').then(function(records) { - assert.equal(get(records, 'text'), 'Not ok', '1 record was found'); - assert.equal(get(records, 'votes'), 566, '1 record was found'); - assert.equal(get(records, 'moderated'), false, '1 record was found'); - }).finally(done5); }); -}); - -test('find all records', function (assert) { - assert.expect(1); - let done = assert.async(); - run(function () { - storeOfflineCrudTest.findAll('ember-flexberry-dummy-suggestion').then(function(records) { - let firstRecord = records.objectAt(0); - assert.equal(get(firstRecord, 'address'), 'Street, 20', '1 record was found'); - }).finally(done); - }); -}); -test('query record via query', function (assert) { - assert.expect(2); - let done1 = assert.async(); - run(function () { - storeOfflineCrudTest.query('ember-flexberry-dummy-suggestion', { address: 'Street, 20' }).then(function(records) { - let firstRecord = records.objectAt(0); - assert.equal(get(firstRecord, 'address'), 'Street, 20', '1 record was found without query language'); - }).finally(done1); + test('find record', function (assert) { + assert.expect(13); + let done1 = assert.async(); + run(function () { + storeOfflineCrudTest.findRecord('ember-flexberry-dummy-suggestion', 'fea5b275-cb9b-4584-ba04-26122bc8cbd3').then(function(records) { + assert.equal(get(records, 'address'), 'Street, 20', 'record address = Street, 20'); + assert.equal(get(records, 'text'), 'Loooong text', 'record text = Loooong text'); + assert.equal(get(records, 'votes'), 1, 'record votes = 1'); + assert.equal(get(records, 'moderated'), false, '1 record was found'); + }).finally(done1); + }); + let done2 = assert.async(); + run(function () { + storeOfflineCrudTest.findRecord('ember-flexberry-dummy-suggestion-type', 'de627522-47c3-428f-99be-fdac2e8f5618').then(function(records) { + assert.equal(get(records, 'name'), '123', '1 record was found'); + assert.equal(get(records, 'moderated'), false, '1 record was found'); + }).finally(done2); + }); + let done3 = assert.async(); + run(function () { + storeOfflineCrudTest.findRecord('ember-flexberry-dummy-application-user', '555a6d25-ac76-417c-bcc5-25bc260fc3ae').then(function(records) { + assert.equal(get(records, 'name'), 'Васиииилий', '1 record was found'); + assert.equal(get(records, 'eMail'), 'pupkin1@mail.ru', '1 record was found'); + assert.equal(get(records, 'activated'), true, '1 record was found'); + }).finally(done3); + }); + let done4 = assert.async(); + run(function () { + storeOfflineCrudTest.findRecord('ember-flexberry-dummy-vote', '8be0d89b-8cab-4b0b-b029-356c59809163').then(function(records) { + assert.equal(get(records, 'voteType'), 'Like', '1 record was found'); + }).finally(done4); + }); + let done5 = assert.async(); + run(function () { + storeOfflineCrudTest.findRecord('ember-flexberry-dummy-comment', '7e5d3b63-eb5e-446e-84da-26865f87c1c5').then(function(records) { + assert.equal(get(records, 'text'), 'Not ok', '1 record was found'); + assert.equal(get(records, 'votes'), 566, '1 record was found'); + assert.equal(get(records, 'moderated'), false, '1 record was found'); + }).finally(done5); + }); }); - let done2 = assert.async(); - run(function () { - let modelName = 'ember-flexberry-dummy-suggestion'; - let builder = new Builder(storeOfflineCrudTest, modelName).selectByProjection('SuggestionL').where('address', FilterOperator.Eq, 'Street, 20'); - storeOfflineCrudTest.query(modelName, builder.build()).then(function(records) { - let firstRecord = records.objectAt(0); - assert.equal(get(firstRecord, 'address'), 'Street, 20', '1 record was found with query language'); - }).finally(done2); + test('find all records', function (assert) { + assert.expect(1); + let done = assert.async(); + run(function () { + storeOfflineCrudTest.findAll('ember-flexberry-dummy-suggestion').then(function(records) { + let firstRecord = records.objectAt(0); + assert.equal(get(firstRecord, 'address'), 'Street, 20', '1 record was found'); + }).finally(done); + }); }); -}); -test('query record via queryRecord', function (assert) { - assert.expect(2); - let done1 = assert.async(); - run(function () { - storeOfflineCrudTest.queryRecord('ember-flexberry-dummy-suggestion', { address: 'Street, 20' }).then(function(record) { - assert.equal(get(record, 'address'), 'Street, 20', '1 record was found without query language'); - }).finally(done1); - }); + test('query record via query', function (assert) { + assert.expect(2); + let done1 = assert.async(); + run(function () { + storeOfflineCrudTest.query('ember-flexberry-dummy-suggestion', { address: 'Street, 20' }).then(function(records) { + let firstRecord = records.objectAt(0); + assert.equal(get(firstRecord, 'address'), 'Street, 20', '1 record was found without query language'); + }).finally(done1); + }); - let done2 = assert.async(); - run(function () { - let modelName = 'ember-flexberry-dummy-suggestion'; - let builder = new Builder(storeOfflineCrudTest, modelName).selectByProjection('SuggestionL').where('address', FilterOperator.Eq, 'Street, 20'); - storeOfflineCrudTest.queryRecord(modelName, builder.build()).then(function(record) { - assert.equal(get(record, 'address'), 'Street, 20', '1 record was found with query language'); - }).finally(done2); + let done2 = assert.async(); + run(function () { + let modelName = 'ember-flexberry-dummy-suggestion'; + let builder = new Builder(storeOfflineCrudTest, modelName).selectByProjection('SuggestionL').where('address', FilterOperator.Eq, 'Street, 20'); + storeOfflineCrudTest.query(modelName, builder.build()).then(function(records) { + let firstRecord = records.objectAt(0); + assert.equal(get(firstRecord, 'address'), 'Street, 20', '1 record was found with query language'); + }).finally(done2); + }); }); -}); -test('create record', function(assert) { - assert.expect(3); - let done = assert.async(); + test('query record via queryRecord', function (assert) { + assert.expect(2); + let done1 = assert.async(); + run(function () { + storeOfflineCrudTest.queryRecord('ember-flexberry-dummy-suggestion', { address: 'Street, 20' }).then(function(record) { + assert.equal(get(record, 'address'), 'Street, 20', '1 record was found without query language'); + }).finally(done1); + }); - run(function() { - let list = storeOfflineCrudTest.createRecord('ember-flexberry-dummy-application-user', { - name: 'чел', - eMail: 'pupkin1@mail.ru', - phone1: '+790356568933', - phone2: '', - phone3: '+790356568935', - activated: true, - vK: '', - facebook: '', - twitter: '', - birthday: new Date(1997, 5, 11), - gender: 'Male', - vip: true, - karma: 11.4 + let done2 = assert.async(); + run(function () { + let modelName = 'ember-flexberry-dummy-suggestion'; + let builder = new Builder(storeOfflineCrudTest, modelName).selectByProjection('SuggestionL').where('address', FilterOperator.Eq, 'Street, 20'); + storeOfflineCrudTest.queryRecord(modelName, builder.build()).then(function(record) { + assert.equal(get(record, 'address'), 'Street, 20', '1 record was found with query language'); + }).finally(done2); }); + }); + + test('create record', function(assert) { + assert.expect(3); + let done = assert.async(); - list.save().then(function() { - return storeOfflineCrudTest.query('ember-flexberry-dummy-application-user', { - name: 'чел' + run(function() { + let list = storeOfflineCrudTest.createRecord('ember-flexberry-dummy-application-user', { + name: 'чел', + eMail: 'pupkin1@mail.ru', + phone1: '+790356568933', + phone2: '', + phone3: '+790356568935', + activated: true, + vK: '', + facebook: '', + twitter: '', + birthday: new Date(1997, 5, 11), + gender: 'Male', + vip: true, + karma: 11.4 }); - }).then(function(records) { - let record = records.objectAt(0); - assert.equal(get(records, 'length'), 1, 'Only чел was found'); - assert.equal(get(record, 'name'), 'чел', 'Correct name'); - assert.equal(get(record, 'id'), list.id, 'Correct, original id'); - }).finally(done); + + list.save().then(function() { + return storeOfflineCrudTest.query('ember-flexberry-dummy-application-user', { + name: 'чел' + }); + }).then(function(records) { + let record = records.objectAt(0); + assert.equal(get(records, 'length'), 1, 'Only чел was found'); + assert.equal(get(record, 'name'), 'чел', 'Correct name'); + assert.equal(get(record, 'id'), list.id, 'Correct, original id'); + }).finally(done); + }); }); -}); -test('delete record', function(assert) { - assert.expect(2); - let done = assert.async(); + test('delete record', function(assert) { + assert.expect(2); + let done = assert.async(); + + run(function() { + let AssertListIsDeleted = function() { + return storeOfflineCrudTest.query('ember-flexberry-dummy-application-user', { + name: 'Васиииилий' + }).then(function(records) { + assert.equal(get(records, 'length'), 0, 'No record was found'); + }).finally(done); + }; - run(function() { - let AssertListIsDeleted = function() { - return storeOfflineCrudTest.query('ember-flexberry-dummy-application-user', { + storeOfflineCrudTest.query('ember-flexberry-dummy-application-user', { name: 'Васиииилий' }).then(function(records) { - assert.equal(get(records, 'length'), 0, 'No record was found'); - }).finally(done); - }; - - storeOfflineCrudTest.query('ember-flexberry-dummy-application-user', { - name: 'Васиииилий' - }).then(function(records) { - let record = records.objectAt(0); - assert.equal(get(record, 'id'), '555a6d25-ac76-417c-bcc5-25bc260fc3ae', 'Item exists'); - record.destroyRecord().then(AssertListIsDeleted); + let record = records.objectAt(0); + assert.equal(get(record, 'id'), '555a6d25-ac76-417c-bcc5-25bc260fc3ae', 'Item exists'); + record.destroyRecord().then(AssertListIsDeleted); + }); }); }); }); diff --git a/tests/unit/serializers/base-test.js b/tests/unit/serializers/base-test.js index cc39de95..83755a7d 100644 --- a/tests/unit/serializers/base-test.js +++ b/tests/unit/serializers/base-test.js @@ -1,15 +1,16 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { run } from '@ember/runloop'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('model', 'Unit | Serializer | base', { - // Specify the other units that are required for this test. - needs: ['serializer:base'] -}); - -// Replace this with your real tests. -test('it serializes records', function(assert) { - let record = this.subject(); - - let serializedRecord = record.serialize(); +module('Unit | Serializer | base', function(hooks) { + setupTest(hooks); - assert.ok(serializedRecord); + test('it serializes records', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + let record = store.createRecord('model'); + let serializedRecord = record.serialize(); + assert.ok(serializedRecord); + }); + }); }); diff --git a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-offline-test.js b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-offline-test.js index 9a277efe..a7f33944 100644 --- a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-offline-test.js +++ b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-offline-test.js @@ -1,5 +1,5 @@ import { run } from '@ember/runloop'; -import { moduleForModel, test } from 'ember-qunit'; +import { module, test } from 'qunit'; import BaseStore from 'ember-flexberry-data/stores/base-store'; import LocalStore from 'ember-flexberry-data/stores/local-store'; import OfflineSerializer from 'ember-flexberry-data/serializers/offline'; @@ -8,33 +8,26 @@ import startApp from 'dummy/tests/helpers/start-app'; let App; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity', 'Unit | Serializer | audit-entity-offline', { - needs: [ - 'serializer:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-offline', - 'transform:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-t-execution-variant', - 'transform:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-t-type-of-audit-operation', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-security-agent', - ], - - beforeEach() { +module('Unit | Serializer | audit-entity-offline', function(hooks) { + hooks.beforeEach(function() { App = startApp(); App.unregister('service:store'); App.register('service:store', BaseStore); App.register('store:local', LocalStore); - }, + }); - afterEach() { + hooks.afterEach(function() { run(App, 'destroy'); - }, -}); + }); -test('this is a sure serializer', function(assert) { - let record = this.subject(App.__container__.ownerInjection()); - let store = App.resolveRegistration('service:store').create(App.__container__.ownerInjection()); - let onlineSerializer = store.serializerFor(record._createSnapshot().modelName, true); - let offlineSerializer = store.serializerFor(record._createSnapshot().modelName, false); - assert.ok(onlineSerializer instanceof OdataSerializer); - assert.ok(offlineSerializer instanceof OfflineSerializer); + test('this is a correct serializer', function(assert) { + run(() => { + let store = App.resolveRegistration('service:store').create(App.__container__.ownerInjection()); + let record = store.createRecord('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity'); + let onlineSerializer = store.serializerFor(record._createSnapshot().modelName, true); + let offlineSerializer = store.serializerFor(record._createSnapshot().modelName, false); + assert.ok(onlineSerializer instanceof OdataSerializer); + assert.ok(offlineSerializer instanceof OfflineSerializer); + }); + }); }); diff --git a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-test.js b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-test.js index 78f7eee4..5e6ca14b 100644 --- a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-test.js +++ b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity-test.js @@ -1,18 +1,16 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { run } from '@ember/runloop'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity', 'Unit | Serializer | audit-entity', { - needs: [ - 'serializer:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity', - 'transform:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-t-execution-variant', - 'transform:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-t-type-of-audit-operation', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-security-agent', - ], -}); +module('Unit | Serializer | audit-entity', function(hooks) { + setupTest(hooks); -test('it serializes records', function(assert) { - let record = this.subject(); - let serializedRecord = record.serialize(); - assert.ok(serializedRecord); + test('it serializes records', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + let record = store.createRecord('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity'); + let serializedRecord = record.serialize(); + assert.ok(serializedRecord); + }); + }); }); diff --git a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-offline-test.js b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-offline-test.js index acabc16e..d796c580 100644 --- a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-offline-test.js +++ b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-offline-test.js @@ -1,5 +1,5 @@ import { run } from '@ember/runloop'; -import { moduleForModel, test } from 'ember-qunit'; +import { module, test } from 'qunit'; import BaseStore from 'ember-flexberry-data/stores/base-store'; import LocalStore from 'ember-flexberry-data/stores/local-store'; import OfflineSerializer from 'ember-flexberry-data/serializers/offline'; @@ -8,29 +8,26 @@ import startApp from 'dummy/tests/helpers/start-app'; let App; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field', 'Unit | Serializer | audit-field-offline', { - needs: [ - 'serializer:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-offline', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity', - ], - - beforeEach() { +module('Unit | Serializer | audit-field-offline', function(hooks) { + hooks.beforeEach(function() { App = startApp(); App.unregister('service:store'); App.register('service:store', BaseStore); App.register('store:local', LocalStore); - }, + }); - afterEach() { + hooks.afterEach(function() { run(App, 'destroy'); - }, -}); + }); -test('it serializes records', function(assert) { - let record = this.subject(App.__container__.ownerInjection()); - let store = App.resolveRegistration('service:store').create(App.__container__.ownerInjection()); - let onlineSerializer = store.serializerFor(record._createSnapshot().modelName, true); - let offlineSerializer = store.serializerFor(record._createSnapshot().modelName, false); - assert.ok(onlineSerializer instanceof OdataSerializer); - assert.ok(offlineSerializer instanceof OfflineSerializer); + test('this is a correct serializer', function(assert) { + run(() => { + let store = App.resolveRegistration('service:store').create(App.__container__.ownerInjection()); + let record = store.createRecord('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field'); + let onlineSerializer = store.serializerFor(record._createSnapshot().modelName, true); + let offlineSerializer = store.serializerFor(record._createSnapshot().modelName, false); + assert.ok(onlineSerializer instanceof OdataSerializer); + assert.ok(offlineSerializer instanceof OfflineSerializer); + }); + }); }); diff --git a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-test.js b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-test.js index f86a0577..a3f6d2c3 100644 --- a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-test.js +++ b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field-test.js @@ -1,14 +1,16 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { run } from '@ember/runloop'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field', 'Unit | Serializer | audit-field', { - needs: [ - 'serializer:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-entity', - ], -}); +module('Unit | Serializer | audit-field', function(hooks) { + setupTest(hooks); -test('it serializes records', function(assert) { - let record = this.subject(); - let serializedRecord = record.serialize(); - assert.ok(serializedRecord); + test('it serializes records', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + let record = store.createRecord('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-audit-field'); + let serializedRecord = record.serialize(); + assert.ok(serializedRecord); + }); + }); }); diff --git a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-offline-test.js b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-offline-test.js index 2903180d..80d3fab2 100644 --- a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-offline-test.js +++ b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-offline-test.js @@ -1,5 +1,5 @@ import { run } from '@ember/runloop'; -import { moduleForModel, test } from 'ember-qunit'; +import { module, test } from 'qunit'; import BaseStore from 'ember-flexberry-data/stores/base-store'; import LocalStore from 'ember-flexberry-data/stores/local-store'; import OfflineSerializer from 'ember-flexberry-data/serializers/offline'; @@ -8,28 +8,26 @@ import startApp from 'dummy/tests/helpers/start-app'; let App; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type', 'Unit | Serializer | object-type-offline', { - needs: [ - 'serializer:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-offline', - ], - - beforeEach() { +module('Unit | Serializer | object-type-offline', function(hooks) { + hooks.beforeEach(function() { App = startApp(); App.unregister('service:store'); App.register('service:store', BaseStore); App.register('store:local', LocalStore); - }, + }); - afterEach() { + hooks.afterEach(function() { run(App, 'destroy'); - }, -}); + }); -test('it serializes records', function(assert) { - let record = this.subject(App.__container__.ownerInjection()); - let store = App.resolveRegistration('service:store').create(App.__container__.ownerInjection()); - let onlineSerializer = store.serializerFor(record._createSnapshot().modelName, true); - let offlineSerializer = store.serializerFor(record._createSnapshot().modelName, false); - assert.ok(onlineSerializer instanceof OdataSerializer); - assert.ok(offlineSerializer instanceof OfflineSerializer); + test('this is a correct serializer', function(assert) { + run(() => { + let store = App.resolveRegistration('service:store').create(App.__container__.ownerInjection()); + let record = store.createRecord('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type'); + let onlineSerializer = store.serializerFor(record._createSnapshot().modelName, true); + let offlineSerializer = store.serializerFor(record._createSnapshot().modelName, false); + assert.ok(onlineSerializer instanceof OdataSerializer); + assert.ok(offlineSerializer instanceof OfflineSerializer); + }); + }); }); diff --git a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-test.js b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-test.js index e8dcff1c..27f5149d 100644 --- a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-test.js +++ b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type-test.js @@ -1,13 +1,16 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { run } from '@ember/runloop'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type', 'Unit | Serializer | object-type', { - needs: [ - 'serializer:i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type', - ], -}); +module('Unit | Serializer | object-type', function(hooks) { + setupTest(hooks); -test('it serializes records', function(assert) { - let record = this.subject(); - let serializedRecord = record.serialize(); - assert.ok(serializedRecord); + test('it serializes records', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + let record = store.createRecord('i-c-s-soft-s-t-o-r-m-n-e-t-business-audit-objects-object-type'); + let serializedRecord = record.serialize(); + assert.ok(serializedRecord); + }); + }); }); diff --git a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-offline-test.js b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-offline-test.js index aa0f258c..acba22b7 100644 --- a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-offline-test.js +++ b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-offline-test.js @@ -1,5 +1,5 @@ import { run } from '@ember/runloop'; -import { moduleForModel, test } from 'ember-qunit'; +import { module, test } from 'qunit'; import BaseStore from 'ember-flexberry-data/stores/base-store'; import LocalStore from 'ember-flexberry-data/stores/local-store'; import OfflineSerializer from 'ember-flexberry-data/serializers/offline'; @@ -8,28 +8,26 @@ import startApp from 'dummy/tests/helpers/start-app'; let App; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-security-agent', 'Unit | Serializer | agent-offline', { - needs: [ - 'serializer:i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-offline', - ], - - beforeEach() { +module('Unit | Serializer | agent-offline', function(hooks) { + hooks.beforeEach(function() { App = startApp(); App.unregister('service:store'); App.register('service:store', BaseStore); App.register('store:local', LocalStore); - }, + }); - afterEach() { + hooks.afterEach(function() { run(App, 'destroy'); - }, -}); + }); -test('this is a sure serializer', function(assert) { - let record = this.subject(App.__container__.ownerInjection()); - let store = App.resolveRegistration('service:store').create(App.__container__.ownerInjection()); - let onlineSerializer = store.serializerFor(record._createSnapshot().modelName, true); - let offlineSerializer = store.serializerFor(record._createSnapshot().modelName, false); - assert.ok(onlineSerializer instanceof OdataSerializer); - assert.ok(offlineSerializer instanceof OfflineSerializer); + test('this is a correct serializer', function(assert) { + run(() => { + let store = App.resolveRegistration('service:store').create(App.__container__.ownerInjection()); + let record = store.createRecord('i-c-s-soft-s-t-o-r-m-n-e-t-security-agent'); + let onlineSerializer = store.serializerFor(record._createSnapshot().modelName, true); + let offlineSerializer = store.serializerFor(record._createSnapshot().modelName, false); + assert.ok(onlineSerializer instanceof OdataSerializer); + assert.ok(offlineSerializer instanceof OfflineSerializer); + }); + }); }); diff --git a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-test.js b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-test.js index 93eb7e7e..8e2c4ba8 100644 --- a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-test.js +++ b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-agent-test.js @@ -1,13 +1,16 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { run } from '@ember/runloop'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-security-agent', 'Unit | Serializer | agent', { - needs: [ - 'serializer:i-c-s-soft-s-t-o-r-m-n-e-t-security-agent', - ], -}); +module('Unit | Serializer | agent', function(hooks) { + setupTest(hooks); -test('it serializes records', function(assert) { - let record = this.subject(); - let serializedRecord = record.serialize(); - assert.ok(serializedRecord); + test('it serializes records', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + let record = store.createRecord('i-c-s-soft-s-t-o-r-m-n-e-t-security-agent'); + let serializedRecord = record.serialize(); + assert.ok(serializedRecord); + }); + }); }); diff --git a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group-test.js b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group-test.js index 2cb5c8a8..64010d62 100644 --- a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group-test.js +++ b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group-test.js @@ -1,15 +1,16 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { run } from '@ember/runloop'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group', 'Unit | Serializer | link-group', { - needs: [ - 'serializer:i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group', - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-security-agent', - 'service:syncer', - ], -}); +module('Unit | Serializer | link-group', function(hooks) { + setupTest(hooks); -test('it serializes records', function(assert) { - let record = this.subject(); - let serializedRecord = record.serialize(); - assert.ok(serializedRecord); + test('it serializes records', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + let record = store.createRecord('i-c-s-soft-s-t-o-r-m-n-e-t-security-link-group'); + let serializedRecord = record.serialize(); + assert.ok(serializedRecord); + }); + }); }); diff --git a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-session-test.js b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-session-test.js index 674cca03..8f376f86 100644 --- a/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-session-test.js +++ b/tests/unit/serializers/i-c-s-soft-s-t-o-r-m-n-e-t-security-session-test.js @@ -1,14 +1,16 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { run } from '@ember/runloop'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleForModel('i-c-s-soft-s-t-o-r-m-n-e-t-security-session', 'Unit | Serializer | session', { - needs: [ - 'serializer:i-c-s-soft-s-t-o-r-m-n-e-t-security-session', - 'service:syncer', - ], -}); +module('Unit | Serializer | session', function(hooks) { + setupTest(hooks); -test('it serializes records', function(assert) { - let record = this.subject(); - let serializedRecord = record.serialize(); - assert.ok(serializedRecord); + test('it serializes records', function(assert) { + run(() => { + let store = this.owner.lookup('service:store'); + let record = store.createRecord('i-c-s-soft-s-t-o-r-m-n-e-t-security-session'); + let serializedRecord = record.serialize(); + assert.ok(serializedRecord); + }); + }); }); diff --git a/tests/unit/serializers/odata-test.js b/tests/unit/serializers/odata-test.js deleted file mode 100644 index 7e09feb9..00000000 --- a/tests/unit/serializers/odata-test.js +++ /dev/null @@ -1,15 +0,0 @@ -import { moduleForModel, test } from 'ember-qunit'; - -moduleForModel('model', 'Unit | Serializer | odata', { - // Specify the other units that are required for this test. - needs: ['serializer:odata'] -}); - -// Replace this with your real tests. -test('it serializes records', function(assert) { - let record = this.subject(); - - let serializedRecord = record.serialize(); - - assert.ok(serializedRecord); -}); diff --git a/tests/unit/serializers/offline-test.js b/tests/unit/serializers/offline-test.js deleted file mode 100644 index 651a7e2f..00000000 --- a/tests/unit/serializers/offline-test.js +++ /dev/null @@ -1,15 +0,0 @@ -import { moduleForModel, test } from 'ember-qunit'; - -moduleForModel('model', 'Unit | Serializer | offline', { - // Specify the other units that are required for this test. - needs: ['serializer:offline'] -}); - -// Replace this with your real tests. -test('it serializes records', function(assert) { - let record = this.subject(); - - let serializedRecord = record.serialize(); - - assert.ok(serializedRecord); -}); diff --git a/tests/unit/services/dexie-test.js b/tests/unit/services/dexie-test.js index 278a1681..aa04f6fb 100644 --- a/tests/unit/services/dexie-test.js +++ b/tests/unit/services/dexie-test.js @@ -1,12 +1,11 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('service:dexie', 'Unit | Service | dexie', { - // Specify the other units that are required for this test. - // needs: ['service:foo'] -}); +module('Unit | Service | dexie', function(hooks) { + setupTest(hooks); -// Replace this with your real tests. -test('it exists', function(assert) { - let service = this.subject(); - assert.ok(service); + test('it exists', function(assert) { + let service = this.owner.lookup('service:dexie'); + assert.ok(service); + }); }); diff --git a/tests/unit/services/offline-globals-test.js b/tests/unit/services/offline-globals-test.js index dc11bb20..42ddbcc6 100644 --- a/tests/unit/services/offline-globals-test.js +++ b/tests/unit/services/offline-globals-test.js @@ -1,25 +1,11 @@ -import { run } from '@ember/runloop'; -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -import startApp from '../../helpers/start-app'; +module('Unit | Service | offline-globals', function(hooks) { + setupTest(hooks); -let App; - -moduleFor('service:offline-globals', 'Unit | Service | offline globals', { - // Specify the other units that are required for this test. - // needs: ['service:foo'] - - beforeEach() { - App = startApp(); - }, - - afterEach() { - run(App, 'destroy'); - } -}); - -// Replace this with your real tests. -test('it exists', function(assert) { - let service = this.subject(App.__container__.ownerInjection()); - assert.ok(service); + test('it exists', function(assert) { + let service = this.owner.lookup('service:offline-globals'); + assert.ok(service); + }); }); diff --git a/tests/unit/services/syncer-test.js b/tests/unit/services/syncer-test.js index 2828d9bb..79089ae7 100644 --- a/tests/unit/services/syncer-test.js +++ b/tests/unit/services/syncer-test.js @@ -1,82 +1,67 @@ import { run } from '@ember/runloop'; -import { moduleFor, test } from 'ember-qunit'; -import startApp from 'dummy/tests/helpers/start-app'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -let App; +module('Unit | Service | syncer', function(hooks) { + setupTest(hooks); -moduleFor('service:syncer', 'Unit | Service | syncer', { - needs: [ - 'model:ember-flexberry-dummy-application-user', - ], - - beforeEach() { - App = startApp(); - }, - - afterEach() { - run(App, 'destroy'); - }, -}); - -test('it exists', function(assert) { - let service = this.subject(App.__container__.ownerInjection()); - assert.ok(service, 'Syncer exists.'); -}); - -test('operation type from dirty type', function(assert) { - let syncer = this.subject(App.__container__.ownerInjection()); + test('it exists', function(assert) { + let service = this.owner.lookup('service:syncer'); + assert.ok(service); + }); - assert.equal(syncer._getOperationType('created'), 'INSERT', `'created' === 'INSERT'`); - assert.equal(syncer._getOperationType('updated'), 'UPDATE', `'updated' === 'UPDATE'`); - assert.equal(syncer._getOperationType('deleted'), 'DELETE', `'deleted' === 'DELETE'`); - assert.throws(() => { - syncer._getOperationType(); - syncer._getOperationType(''); - syncer._getOperationType('other'); - }, Error('Unknown dirty type.'), 'Other dirty type throw error.'); -}); + test('operation type from dirty type', function(assert) { + let syncer = this.owner.lookup('service:syncer'); + assert.equal(syncer._getOperationType('created'), 'INSERT', `'created' === 'INSERT'`); + assert.equal(syncer._getOperationType('updated'), 'UPDATE', `'updated' === 'UPDATE'`); + assert.equal(syncer._getOperationType('deleted'), 'DELETE', `'deleted' === 'DELETE'`); + assert.throws(() => { + syncer._getOperationType(); + syncer._getOperationType(''); + syncer._getOperationType('other'); + }, Error('Unknown dirty type.'), 'Other dirty type throw error.'); + }); -test('changes from record', function(assert) { - let syncer = this.subject(App.__container__.ownerInjection()); - let store = App.__container__.lookup('service:store'); + test('changes from record', function(assert) { + let syncer = this.owner.lookup('service:syncer'); + let store = this.owner.lookup('service:store'); + run(() => { + let record = store.createRecord('ember-flexberry-dummy-application-user', { + name: 'name', + eMail: 'eMail', + phone1: 'phone1', + activated: false, + vK: 'vK', + vip: true, + karma: 100, + }); - run(() => { - let record = store.createRecord('ember-flexberry-dummy-application-user', { - name: 'name', - eMail: 'eMail', - phone1: 'phone1', - activated: false, - vK: 'vK', - vip: true, - karma: 100, + assert.deepEqual(syncer._changesFromRecord(record), { + name: [undefined, 'name'], + eMail: [undefined, 'eMail'], + phone1: [undefined, 'phone1'], + activated: [undefined, false], + vK: [undefined, 'vK'], + vip: [undefined, true], + karma: [undefined, 100], + }, 'All changes there.'); }); - - assert.deepEqual(syncer._changesFromRecord(record), { - name: [undefined, 'name'], - eMail: [undefined, 'eMail'], - phone1: [undefined, 'phone1'], - activated: [undefined, false], - vK: [undefined, 'vK'], - vip: [undefined, true], - karma: [undefined, 100], - }, 'All changes there.'); }); -}); -test('get object type', function(assert) { - assert.expect(2); - let done = assert.async(); - let syncer = this.subject(App.__container__.ownerInjection()); - syncer.set('offlineStore', App.__container__.lookup('service:store').get('offlineStore')); + test('get object type', function(assert) { + assert.expect(2); + let done = assert.async(); + let syncer = this.owner.lookup('service:syncer'); + syncer.set('offlineStore', this.owner.lookup('service:store').get('offlineStore')); + run(() => { + syncer._getObjectType('ember-flexberry-dummy-application-user').then((newObjectType) => { + let id = newObjectType.get('id'); + assert.equal(newObjectType.get('name'), 'ember-flexberry-dummy-application-user', `Created 'objectType' model instance.`); - run(() => { - syncer._getObjectType('ember-flexberry-dummy-application-user').then((newObjectType) => { - let id = newObjectType.get('id'); - assert.equal(newObjectType.get('name'), 'ember-flexberry-dummy-application-user', `Created 'objectType' model instance.`); - - return syncer._getObjectType('ember-flexberry-dummy-application-user').then((objectType) => { - assert.equal(objectType.get('id'), id, `Return exist 'objectType' model instance.`); - }); - }).finally(done); + return syncer._getObjectType('ember-flexberry-dummy-application-user').then((objectType) => { + assert.equal(objectType.get('id'), id, `Return exist 'objectType' model instance.`); + }); + }).finally(done); + }); }); }); diff --git a/tests/unit/services/user-test.js b/tests/unit/services/user-test.js index 182390a6..c5d2548a 100644 --- a/tests/unit/services/user-test.js +++ b/tests/unit/services/user-test.js @@ -1,30 +1,11 @@ -import { run } from '@ember/runloop'; -import { moduleFor, test } from 'ember-qunit'; -import BaseStore from 'ember-flexberry-data/stores/base-store'; -import LocalStore from 'ember-flexberry-data/stores/local-store'; -import startApp from 'dummy/tests/helpers/start-app'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -let App; +module('Unit | Service | user', function(hooks) { + setupTest(hooks); -moduleFor('service:user', 'Unit | Service | user', { - needs: [ - 'model:i-c-s-soft-s-t-o-r-m-n-e-t-security-agent', - ], - - beforeEach() { - App = startApp(); - App.unregister('service:store'); - App.register('service:store', BaseStore); - App.register('store:local', LocalStore); - }, - - afterEach() { - run(App, 'destroy'); - }, -}); - -test('it works', function(assert) { - // TODO: Replace this with your real tests. - let service = this.subject(App.__container__.ownerInjection()); - assert.ok(!!service); + test('it exists', function(assert) { + let service = this.owner.lookup('service:user'); + assert.ok(service); + }); }); diff --git a/tests/unit/transforms/decimal-test.js b/tests/unit/transforms/decimal-test.js index f6676398..00c82000 100644 --- a/tests/unit/transforms/decimal-test.js +++ b/tests/unit/transforms/decimal-test.js @@ -1,19 +1,20 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; -moduleFor('transform:decimal', 'Unit | Transform | decimal'); +module('Unit | Transform | decimal', function(hooks) { + setupTest(hooks); -test('serialize', function(assert) { - let transform = this.subject(); + test('serialize', function(assert) { + let transform = this.owner.lookup('transform:decimal'); + assert.strictEqual(transform.serialize(555.5), 555.5); + assert.strictEqual(transform.serialize('555.5'), 555.5); + assert.strictEqual(transform.serialize('555,5'), 555.5); + }); - assert.strictEqual(transform.serialize(555.5), 555.5); - assert.strictEqual(transform.serialize('555.5'), 555.5); - assert.strictEqual(transform.serialize('555,5'), 555.5); -}); - -test('deserialize', function(assert) { - let transform = this.subject(); - - assert.strictEqual(transform.deserialize(555.5), 555.5); - assert.strictEqual(transform.deserialize('555.5'), 555.5); - assert.strictEqual(transform.deserialize('555,5'), 555.5); + test('deserialize', function(assert) { + let transform = this.owner.lookup('transform:decimal'); + assert.strictEqual(transform.deserialize(555.5), 555.5); + assert.strictEqual(transform.deserialize('555.5'), 555.5); + assert.strictEqual(transform.deserialize('555,5'), 555.5); + }); }); diff --git a/tests/unit/transforms/flexberry-enum-test.js b/tests/unit/transforms/flexberry-enum-test.js index 58ed28dc..9468bb08 100644 --- a/tests/unit/transforms/flexberry-enum-test.js +++ b/tests/unit/transforms/flexberry-enum-test.js @@ -1,65 +1,59 @@ -import { moduleFor, test } from 'ember-qunit'; +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; import { createEnum } from 'ember-flexberry-data/utils/enum-functions'; -moduleFor('transform:flexberry-enum', 'Unit | Transform | flexberry enum', { -}); - -let stringEnum = createEnum({ +const stringEnum = createEnum({ enumValue: 'Value for string enum property' }); -let numberEnum = createEnum({ +const numberEnum = createEnum({ 32: 'Value for number enum property' }); -test('it should throw exception if no enum property set', function(assert) { - assert.throws(() => { - this.subject(); - }); -}); +module('transform:flexberry-enum', 'Unit | Transform | flexberry enum', function(hooks) { + setupTest(hooks); -test('it should throw exception if enum not contains value for deserialize', function(assert) { - let transform = this.subject({ enum: stringEnum }); - assert.throws(() => { - transform.deserialize('notExistEnumValue'); + test('it should throw exception if no enum property set', function(assert) { + assert.throws(() => { + this.owner.lookup('transform:flexberry-enum'); + }); }); -}); -test('it should throw exception if enum not contains property to serialize', function(assert) { - let transform = this.subject({ enum: stringEnum }); - assert.throws(() => { - transform.serialize('Value for string enum property that not exists'); + test('it should throw exception if enum not contains value for deserialize', function(assert) { + let transform = this.owner.resolveRegistration('transform:flexberry-enum').create({ enum: stringEnum}); + assert.throws(() => { + transform.deserialize('notExistEnumValue'); + }); }); -}); - -test('it should deserialize enum value for string enums', function(assert) { - let transform = this.subject({ enum: stringEnum }); - - let deserialized = transform.deserialize('enumValue'); - - assert.equal(deserialized, 'Value for string enum property'); -}); - -test('it should serialize enum property for string enums', function(assert) { - let transform = this.subject({ enum: stringEnum }); - let serialized = transform.serialize('Value for string enum property'); - - assert.equal(serialized, 'enumValue'); -}); - -test('it should deserialize enum value for number enums', function(assert) { - let transform = this.subject({ enum: numberEnum }); - - let deserialized = transform.deserialize(32); + test('it should throw exception if enum not contains property to serialize', function(assert) { + let transform = this.owner.resolveRegistration('transform:flexberry-enum').create({ enum: stringEnum}); + assert.throws(() => { + transform.serialize('Value for string enum property that not exists'); + }); + }); - assert.equal(deserialized, 'Value for number enum property'); -}); + test('it should deserialize enum value for string enums', function(assert) { + let transform = this.owner.resolveRegistration('transform:flexberry-enum').create({ enum: stringEnum}); + let deserialized = transform.deserialize('enumValue'); + assert.equal(deserialized, 'Value for string enum property'); + }); -test('it should serialize enum property for number enums', function(assert) { - let transform = this.subject({ enum: numberEnum }); + test('it should serialize enum property for string enums', function(assert) { + let transform = this.owner.resolveRegistration('transform:flexberry-enum').create({ enum: stringEnum}); + let serialized = transform.serialize('Value for string enum property'); + assert.equal(serialized, 'enumValue'); + }); - let serialized = transform.serialize('Value for number enum property'); + test('it should deserialize enum value for number enums', function(assert) { + let transform = this.owner.resolveRegistration('transform:flexberry-enum').create({ enum: numberEnum}); + let deserialized = transform.deserialize(32); + assert.equal(deserialized, 'Value for number enum property'); + }); - assert.equal(serialized, 32); + test('it should serialize enum property for number enums', function(assert) { + let transform = this.owner.resolveRegistration('transform:flexberry-enum').create({ enum: numberEnum}); + let serialized = transform.serialize('Value for number enum property'); + assert.equal(serialized, 32); + }); }); diff --git a/tests/unit/utils/get-serialized-date-value-test.js b/tests/unit/utils/get-serialized-date-value-test.js index e923ef96..83d39f99 100644 --- a/tests/unit/utils/get-serialized-date-value-test.js +++ b/tests/unit/utils/get-serialized-date-value-test.js @@ -1,26 +1,17 @@ -import { run } from '@ember/runloop'; import { module, test } from 'qunit'; -import startApp from 'dummy/tests/helpers/start-app'; +import { setupTest } from 'ember-qunit'; import getSerializedDateValue from 'ember-flexberry-data/utils/get-serialized-date-value'; -let App; +module('Unit | Utility | get serialized date value', function(hooks) { + setupTest(hooks); -module('Unit | Utility | get serialized date value', { - beforeEach() { - App = startApp(); - }, - - afterEach() { - run(App, 'destroy'); - }, -}); - -test('it works', function(assert) { - let store = App.__container__.lookup('service:store'); - let dateTransform = App.__container__.lookup('transform:date'); - let date = new Date(1981, 10, 12, 13, 14, 15); - let expectedResult = dateTransform.serialize(date); - let result = getSerializedDateValue.call(store, date); - assert.ok(result); - assert.equal(result, expectedResult); + test('it works', function(assert) { + let store = this.owner.lookup('service:store'); + let dateTransform = this.owner.resolveRegistration('transform:date').create(); + let date = new Date(1981, 10, 12, 13, 14, 15); + let expectedResult = dateTransform.serialize(date); + let result = getSerializedDateValue.call(store, date); + assert.ok(result); + assert.equal(result, expectedResult); + }); }); diff --git a/tests/unit/utils/information-test.js b/tests/unit/utils/information-test.js index 0d7694cb..6aec5618 100644 --- a/tests/unit/utils/information-test.js +++ b/tests/unit/utils/information-test.js @@ -1,145 +1,139 @@ -import { run } from '@ember/runloop'; import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; import Information from 'ember-flexberry-data/utils/information'; -import startApp from '../../helpers/start-app'; - -let app; let store; let information; -module('utils', { - beforeEach() { - app = startApp(); - store = app.__container__.lookup('service:store'); - information = new Information(store); - }, - - afterEach() { - run(app, 'destroy'); - }, -}); - -test('information | constructor', assert => { - assert.throws(() => new Information(), Error); - assert.throws(() => new Information(''), Error); - assert.throws(() => new Information('store'), Error); - assert.ok(new Information(store)); -}); - -test('information | isMaster | exceptions', assert => { - assert.throws(() => information.isMaster('unknownmodel', 'firstName'), Error); - assert.throws(() => information.isMaster('customer', 'unknownfield'), Error); - assert.throws(() => information.isMaster('customer', 'Manager.unknownfield'), Error); - assert.throws(() => information.isMaster('customer', 'Manager.Manager.unknownfield'), Error); -}); - -test('information | isMaster | own attribute', assert => { - assert.notOk( - information.isMaster('ember-flexberry-dummy-comment', 'id'), - 'Special attribute `id` is not a master.'); - - assert.notOk( - information.isMaster('ember-flexberry-dummy-comment', 'text'), - 'Own attribute `text` is not a master.'); - - assert.ok( - information.isMaster('ember-flexberry-dummy-comment', 'author'), - 'Relationship `belongsTo` is a master.' - ); - - assert.notOk( - information.isMaster('ember-flexberry-dummy-comment', 'userVotes'), - 'Relationship `hasMany` is not a master.' - ); -}); - -test('information | isMaster | nested', assert => { - assert.notOk(information.isMaster('customer', 'Manager.First Name')); - assert.ok(information.isMaster('customer', 'Manager.Manager')); - assert.ok(information.isMaster('customer', 'Manager.Manager.Manager')); - assert.notOk(information.isMaster('customer', 'Manager.Manager.Manager.First Name')); - assert.notOk(information.isMaster('customer', 'Manager.Manager.Manager.id')); -}); - -test('information | isEnum | own attribute', assert => { - assert.ok(information.getMeta('ember-flexberry-dummy-application-user', 'gender').isEnum); - assert.notOk(information.getMeta('ember-flexberry-dummy-application-user', 'name').isEnum); -}); - -test('information | isEnum | nested', assert => { - assert.ok(information.getMeta('ember-flexberry-dummy-comment-vote', 'applicationUser.gender').isEnum); - assert.notOk(information.getMeta('ember-flexberry-dummy-comment-vote', 'applicationUser.name').isEnum); -}); - -test('information | getType | exceptions', assert => { - assert.throws(() => information.getType('unknownmodel', 'firstName'), Error); - assert.throws(() => information.getType('customer', 'unknownfield'), Error); - assert.throws(() => information.getType('customer', 'Manager.unknownfield'), Error); - assert.throws(() => information.getType('customer', 'Manager.Manager.unknownfield'), Error); -}); - -test('information | getType | own attribute', assert => { - assert.equal(information.getType('customer', 'id'), 'string'); - assert.equal(information.getType('customer', 'Manager'), 'employee'); - assert.equal(information.getType('customer', 'firstName'), 'string'); -}); - -test('information | getType | nested', assert => { - assert.equal(information.getType('customer', 'Manager.First Name'), 'string'); - assert.equal(information.getType('customer', 'Manager.Manager'), 'employee'); - assert.equal(information.getType('customer', 'Manager.Manager.Manager'), 'employee'); - assert.equal(information.getType('customer', 'Manager.Manager.Manager.First Name'), 'string'); - assert.equal(information.getType('customer', 'Manager.Manager.Manager.id'), 'string'); -}); - -test('information | isAttribute | own attribute', function (assert) { - assert.ok(information.isAttribute('ember-flexberry-dummy-suggestion', 'id')); - assert.ok(information.isAttribute('ember-flexberry-dummy-suggestion', 'address')); - assert.notOk(information.isAttribute('ember-flexberry-dummy-suggestion', 'author')); - assert.notOk(information.isAttribute('ember-flexberry-dummy-suggestion', 'userVotes')); -}); +module('Unit | Utility | Information', function(hooks) { + setupTest(hooks); -test('information | isAttribute | nested', function (assert) { - assert.ok(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.id')); - assert.ok(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.name')); - assert.ok(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.parent.name')); - assert.notOk(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.parent')); - assert.notOk(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.parent.parent')); - assert.notOk(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.localizedTypes')); -}); - -test('information | isRelationship | own attribute', function (assert) { - assert.ok(information.isRelationship('ember-flexberry-dummy-suggestion', 'author')); - assert.ok(information.isRelationship('ember-flexberry-dummy-suggestion', 'userVotes')); - assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'id')); - assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'address')); -}); - -test('information | isRelationship | nested', function (assert) { - assert.ok(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.parent')); - assert.ok(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.parent.parent')); - assert.ok(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.localizedTypes')); - assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.id')); - assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.name')); - assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.parent.id')); - assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.parent.name')); -}); - -test('information | isKey | own attribute', function (assert) { - assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'id')); - assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'author')); - assert.notOk(information.isKey('ember-flexberry-dummy-suggestion', 'userVotes')); - assert.notOk(information.isKey('ember-flexberry-dummy-suggestion', 'address')); -}); - -test('information | isKey | nested', function (assert) { - assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'type.id')); - assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'type.parent')); - assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'type.parent.id')); - assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'type.parent.parent')); - assert.notOk(information.isKey('ember-flexberry-dummy-suggestion', 'type.localizedTypes')); - assert.notOk(information.isKey('ember-flexberry-dummy-suggestion', 'type.name')); - assert.notOk(information.isKey('ember-flexberry-dummy-suggestion', 'type.parent.name')); + hooks.beforeEach(function() { + store = this.owner.lookup('service:store'); + information = new Information(store); + }); + + test('information | constructor', assert => { + assert.throws(() => new Information(), Error); + assert.throws(() => new Information(''), Error); + assert.throws(() => new Information('store'), Error); + assert.ok(new Information(store)); + }); + + test('information | isMaster | exceptions', assert => { + assert.throws(() => information.isMaster('unknownmodel', 'firstName'), Error); + assert.throws(() => information.isMaster('customer', 'unknownfield'), Error); + assert.throws(() => information.isMaster('customer', 'Manager.unknownfield'), Error); + assert.throws(() => information.isMaster('customer', 'Manager.Manager.unknownfield'), Error); + }); + + test('information | isMaster | own attribute', assert => { + assert.notOk( + information.isMaster('ember-flexberry-dummy-comment', 'id'), + 'Special attribute `id` is not a master.'); + + assert.notOk( + information.isMaster('ember-flexberry-dummy-comment', 'text'), + 'Own attribute `text` is not a master.'); + + assert.ok( + information.isMaster('ember-flexberry-dummy-comment', 'author'), + 'Relationship `belongsTo` is a master.' + ); + + assert.notOk( + information.isMaster('ember-flexberry-dummy-comment', 'userVotes'), + 'Relationship `hasMany` is not a master.' + ); + }); + + test('information | isMaster | nested', assert => { + assert.notOk(information.isMaster('customer', 'Manager.First Name')); + assert.ok(information.isMaster('customer', 'Manager.Manager')); + assert.ok(information.isMaster('customer', 'Manager.Manager.Manager')); + assert.notOk(information.isMaster('customer', 'Manager.Manager.Manager.First Name')); + assert.notOk(information.isMaster('customer', 'Manager.Manager.Manager.id')); + }); + + test('information | isEnum | own attribute', assert => { + assert.ok(information.getMeta('ember-flexberry-dummy-application-user', 'gender').isEnum); + assert.notOk(information.getMeta('ember-flexberry-dummy-application-user', 'name').isEnum); + }); + + test('information | isEnum | nested', assert => { + assert.ok(information.getMeta('ember-flexberry-dummy-comment-vote', 'applicationUser.gender').isEnum); + assert.notOk(information.getMeta('ember-flexberry-dummy-comment-vote', 'applicationUser.name').isEnum); + }); + + test('information | getType | exceptions', assert => { + assert.throws(() => information.getType('unknownmodel', 'firstName'), Error); + assert.throws(() => information.getType('customer', 'unknownfield'), Error); + assert.throws(() => information.getType('customer', 'Manager.unknownfield'), Error); + assert.throws(() => information.getType('customer', 'Manager.Manager.unknownfield'), Error); + }); + + test('information | getType | own attribute', assert => { + assert.equal(information.getType('customer', 'id'), 'string'); + assert.equal(information.getType('customer', 'Manager'), 'employee'); + assert.equal(information.getType('customer', 'firstName'), 'string'); + }); + + test('information | getType | nested', assert => { + assert.equal(information.getType('customer', 'Manager.First Name'), 'string'); + assert.equal(information.getType('customer', 'Manager.Manager'), 'employee'); + assert.equal(information.getType('customer', 'Manager.Manager.Manager'), 'employee'); + assert.equal(information.getType('customer', 'Manager.Manager.Manager.First Name'), 'string'); + assert.equal(information.getType('customer', 'Manager.Manager.Manager.id'), 'string'); + }); + + test('information | isAttribute | own attribute', function (assert) { + assert.ok(information.isAttribute('ember-flexberry-dummy-suggestion', 'id')); + assert.ok(information.isAttribute('ember-flexberry-dummy-suggestion', 'address')); + assert.notOk(information.isAttribute('ember-flexberry-dummy-suggestion', 'author')); + assert.notOk(information.isAttribute('ember-flexberry-dummy-suggestion', 'userVotes')); + }); + + test('information | isAttribute | nested', function (assert) { + assert.ok(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.id')); + assert.ok(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.name')); + assert.ok(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.parent.name')); + assert.notOk(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.parent')); + assert.notOk(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.parent.parent')); + assert.notOk(information.isAttribute('ember-flexberry-dummy-suggestion', 'type.localizedTypes')); + }); + + test('information | isRelationship | own attribute', function (assert) { + assert.ok(information.isRelationship('ember-flexberry-dummy-suggestion', 'author')); + assert.ok(information.isRelationship('ember-flexberry-dummy-suggestion', 'userVotes')); + assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'id')); + assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'address')); + }); + + test('information | isRelationship | nested', function (assert) { + assert.ok(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.parent')); + assert.ok(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.parent.parent')); + assert.ok(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.localizedTypes')); + assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.id')); + assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.name')); + assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.parent.id')); + assert.notOk(information.isRelationship('ember-flexberry-dummy-suggestion', 'type.parent.name')); + }); + + test('information | isKey | own attribute', function (assert) { + assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'id')); + assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'author')); + assert.notOk(information.isKey('ember-flexberry-dummy-suggestion', 'userVotes')); + assert.notOk(information.isKey('ember-flexberry-dummy-suggestion', 'address')); + }); + + test('information | isKey | nested', function (assert) { + assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'type.id')); + assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'type.parent')); + assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'type.parent.id')); + assert.ok(information.isKey('ember-flexberry-dummy-suggestion', 'type.parent.parent')); + assert.notOk(information.isKey('ember-flexberry-dummy-suggestion', 'type.localizedTypes')); + assert.notOk(information.isKey('ember-flexberry-dummy-suggestion', 'type.name')); + assert.notOk(information.isKey('ember-flexberry-dummy-suggestion', 'type.parent.name')); + }); }); diff --git a/tests/unit/utils/is-embedded-test.js b/tests/unit/utils/is-embedded-test.js index f3e5b84a..57f1fd92 100644 --- a/tests/unit/utils/is-embedded-test.js +++ b/tests/unit/utils/is-embedded-test.js @@ -16,21 +16,21 @@ const serializer = DS.Serializer.extend({ }, }); -module('Unit | Utility | is embedded', { - beforeEach() { +module('Unit | Utility | is embedded', function(hooks) { + hooks.beforeEach(function() { App = startApp(); App.register('model:model', model); App.register('serializer:model', serializer); - }, + }); - afterEach() { + hooks.afterEach(function() { run(App, 'destroy'); - }, -}); + }); -test('it really works', function(assert) { - let store = App.__container__.lookup('service:store'); - assert.notOk(isEmbedded(store, store.modelFor('model'), 'attribute')); - assert.ok(isEmbedded(store, store.modelFor('model'), 'relationship')); - assert.ok(isEmbedded(store, store.modelFor('model'), 'relationships')); + test('isEmbedded is working', function(assert) { + let store = App.__container__.lookup('service:store'); + assert.notOk(isEmbedded(store, store.modelFor('model'), 'attribute')); + assert.ok(isEmbedded(store, store.modelFor('model'), 'relationship')); + assert.ok(isEmbedded(store, store.modelFor('model'), 'relationships')); + }); });