Skip to content

Commit

Permalink
Merge pull request #275 from Flexberry/fix-27-tests-update
Browse files Browse the repository at this point in the history
Update tests structure
  • Loading branch information
TeterinaSvetlana authored Apr 17, 2024
2 parents 273e02a + 367cf30 commit 9cfad73
Show file tree
Hide file tree
Showing 44 changed files with 1,445 additions and 1,627 deletions.
1 change: 1 addition & 0 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
226 changes: 113 additions & 113 deletions tests/integration/adapters/odata-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}));
});
});
});
}
44 changes: 22 additions & 22 deletions tests/integration/display-deep-model-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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);
});
});
});
48 changes: 24 additions & 24 deletions tests/integration/services/store-test.js
Original file line number Diff line number Diff line change
@@ -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: '[email protected]',
}).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: '[email protected]',
}), '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: '[email protected]',
}).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: '[email protected]',
}), 'It is a place for SuperMan.');
}).finally(done);
});
});
});
Loading

0 comments on commit 9cfad73

Please sign in to comment.