Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
AMBARI-25138 Cover mappers files with unit tests. (ababiichuk)
  • Loading branch information
aBabiichuk committed Feb 4, 2019
1 parent b2a0297 commit 100fa13734d223cb0ddd9a3dbae3ec8dc24f7cb1
Showing 10 changed files with 1,038 additions and 23 deletions.
@@ -163,6 +163,8 @@ var files = [
'test/mappers/alert_instances_mapper_test',
'test/mappers/alert_definitions_mapper_test',
'test/mappers/alert_definition_summary_mapper_test',
'test/mappers/alert_notification_mapper_test',
'test/mappers/cluster_mapper_test',
'test/mappers/server_data_mapper_test',
'test/mappers/hosts_mapper_test',
'test/mappers/service_mapper_test',
@@ -171,8 +173,10 @@ var files = [
'test/mappers/users_mapper_test',
'test/mappers/stack_mapper_test',
'test/mappers/stack_service_mapper_test',
'test/mappers/stack_version_mapper_test',
'test/mappers/repository_version_mapper_test',
'test/mappers/stack_upgrade_history_mapper_test',
'test/mappers/widget_mapper_test',
'test/mappers/configs/config_groups_mapper_test',
'test/mappers/configs/service_config_version_mapper_test',
'test/mappers/configs/themes_mapper_test',
@@ -77,7 +77,6 @@ App.alertNotificationMapper = App.QuickDataMapper.create({
* @private
*/
_setPropertiesToEachModel: function (propertyName, propertiesMap) {
var modelsMap = this.get('modelsMap');
for (var recordId in propertiesMap) {
if (propertiesMap.hasOwnProperty(recordId)) {
App.AlertNotification.find(recordId).set(propertyName, propertiesMap[recordId]);
@@ -29,21 +29,5 @@ App.quicklinksMapper = App.QuickDataMapper.create({
"name" : "QuickLinkInfo.quicklink_data.QuickLinksConfiguration.name",
"protocol" : "QuickLinkInfo.quicklink_data.QuickLinksConfiguration.configuration.protocol",
"links" : "QuickLinkInfo.quicklink_data.QuickLinksConfiguration.configuration.links"
},

map: function(json){
console.time('App.quicklinksMapper execution time');

var result = [];
var linkResult = [];

json.items.forEach(function(item) {
var parseResult = this.parseIt(item, this.get('config'));
console.log("parseResult", parseResult);
result.push(parseResult);
}, this);

App.store.safeLoadMany(this.get('model'), result);
console.timeEnd('App.quicklinksMapper execution time');
}
});
@@ -45,10 +45,13 @@ App.Widget = DS.Model.extend({
tag: DS.attr('string'),
isVisible: DS.attr('boolean', {defaultValue: true}),
/**
* This field is not derived from API but needs to be filled in the mapper on the client side
* @type {number}
* @default 0
*/
defaultOrder: 0, // This field is not derived from API but needs to be filled in the mapper on the client side
defaultOrder: DS.attr('number', {
defaultValue: 0
}),

/**
* @type Em.View
@@ -37,11 +37,14 @@ module.exports = {
nestedExpect: function (expected, actual) {
expected.forEach(function (group, i) {
Em.keys(group).forEach(function (key) {
if (Em.isArray(actual[i][key])) {
expect(group[key]).to.eql(actual[i][key].toArray());
}
else {
expect(group[key]).to.equal(actual[i][key]);
var expectedValue = Em.get(group, key),
actualValue = Em.get(actual[i], key);
if (Em.isArray(actualValue)) {
expect(expectedValue).to.eql(actualValue.toArray());
} else if (Em.typeOf(actualValue) === 'object') {
expect(expectedValue).to.eql(actualValue);
} else {
expect(expectedValue).to.equal(actualValue);
}
});
});
@@ -103,6 +103,7 @@ describe('App.alertGroupsMapper', function () {
App.store.loadMany.restore();
App.alertGroupsMapper.set('model', App.AlertGroup);
App.cache.previousAlertGroupsMap = {};
App.cache.alertNotificationsGroupsMap = {};

});

0 comments on commit 100fa13

Please sign in to comment.