Skip to content

Commit

Permalink
feat(type_mapping): rename function to avoid confusion with elasticse…
Browse files Browse the repository at this point in the history
…arch API
  • Loading branch information
missinglink committed May 28, 2018
1 parent 83ab163 commit e15aa52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions helper/TypeMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ TypeMapping.prototype.setLayerAliases = function( aliases ){
this.layer_aliases = aliases;
};

// generate dynamic mappings after setters have been run
TypeMapping.prototype.generateDynamicMappings = function(){
// generate mappings after setters have been run
TypeMapping.prototype.generateMappings = function(){
this.sources = Object.keys( this.layers_by_source );
this.source_mapping = TypeMapping.addStandardTargetsToAliases(this.sources, this.source_aliases);
this.layers = _.uniq(Object.keys(this.layers_by_source).reduce(function(acc, key) {
Expand All @@ -85,8 +85,8 @@ TypeMapping.prototype.loadTargets = function( targetsBlock ){
this.setLayersBySource( targetsBlock.layers_by_source || {} );
this.setLayerAliases( targetsBlock.layer_aliases || {} );

// generate the dynamic mappings
this.generateDynamicMappings();
// generate the mappings
this.generateMappings();
};

// load values from either pelias config file or from elasticsearch
Expand Down Expand Up @@ -143,4 +143,4 @@ TypeMapping.prototype.load = function( done ){
// });
};

module.exports = TypeMapping;
module.exports = TypeMapping;
26 changes: 13 additions & 13 deletions test/unit/helper/TypeMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports.tests.interface = function(test) {
t.equal(typeof TypeMapping.prototype.setLayersBySource, 'function', 'setLayersBySource() is a function');
t.equal(typeof TypeMapping.prototype.setLayerAliases, 'function', 'setLayerAliases() is a function');

t.equal(typeof TypeMapping.prototype.generateDynamicMappings, 'function', 'generateDynamicMappings() is a function');
t.equal(typeof TypeMapping.prototype.generateMappings, 'function', 'generateMappings() is a function');

t.equal(typeof TypeMapping.prototype.loadTargets, 'function', 'loadTargets() is a function');
t.equal(typeof TypeMapping.prototype.load, 'function', 'load() is a function');

Expand Down Expand Up @@ -105,47 +105,47 @@ module.exports.tests.setLayerAliases = function(test) {
});
};

module.exports.tests.generateDynamicMappings = function(test) {
test('generateDynamicMappings - no-op', function(t) {
module.exports.tests.generateMappings = function(test) {
test('generateMappings - no-op', function(t) {
var tm = new TypeMapping();
t.deepEqual(tm.sources, []);
t.deepEqual(tm.source_mapping, {});
t.deepEqual(tm.layers, []);
t.deepEqual(tm.layer_mapping, {});
tm.generateDynamicMappings();
tm.generateMappings();
t.deepEqual(tm.sources, []);
t.deepEqual(tm.source_mapping, {});
t.deepEqual(tm.layers, []);
t.deepEqual(tm.layer_mapping, {});
t.end();
});
test('generateDynamicMappings - sources', function(t) {
test('generateMappings - sources', function(t) {
var tm = new TypeMapping();
tm.layers_by_source = { foo: ['foo'], faz: ['faz'] };
tm.generateDynamicMappings();
tm.generateMappings();
t.deepEqual(tm.sources, ['foo', 'faz']);
t.end();
});
test('generateDynamicMappings - source_mapping', function(t) {
test('generateMappings - source_mapping', function(t) {
var tm = new TypeMapping();
tm.layers_by_source = { foo: ['foo'], faz: ['faz'] };
tm.source_aliases = { foo: ['foo','f'], bar: ['bar', 'b'], baz: ['baz'] };
tm.generateDynamicMappings();
tm.generateMappings();
t.deepEqual(tm.source_mapping, { foo: ['foo', 'f'], bar: ['bar', 'b'], baz: ['baz'], faz: ['faz'] });
t.end();
});
test('generateDynamicMappings - layers', function(t) {
test('generateMappings - layers', function(t) {
var tm = new TypeMapping();
tm.layers_by_source = { foo: ['foo'], faz: ['faz'] };
tm.generateDynamicMappings();
tm.generateMappings();
t.deepEqual(tm.layers, ['foo','faz']);
t.end();
});
test('generateDynamicMappings - layer_mapping', function(t) {
test('generateMappings - layer_mapping', function(t) {
var tm = new TypeMapping();
tm.layers_by_source = { foo: ['foo'], faz: ['faz'] };
tm.layer_aliases = { foo: ['foo','f'], bar: ['bar', 'b'], baz: ['baz'] };
tm.generateDynamicMappings();
tm.generateMappings();
t.deepEqual(tm.layer_mapping, { foo: ['foo', 'f'], bar: ['bar', 'b'], baz: ['baz'], faz: ['faz'] });
t.end();
});
Expand Down

0 comments on commit e15aa52

Please sign in to comment.