Przeglądaj źródła

Fixed init-test.

Mostly renames, new init semantic and I forgot to call
updateTemplateParams in addTemplateParameter
Harald Kraemer 11 lat temu
rodzic
commit
51b70a7884

+ 4 - 2
src/app/services/filterSrv.js

@@ -17,7 +17,7 @@ define([
 
     var result = {
         _updateTemplateData : function( initial ) {
-            this._templateData = {};
+            var _templateData = {};
             _.each(this.templateParameters, function( templateParameter ) {
                 if (initial) {
                     var urlValue = $routeParams[ templateParameter.name ];
@@ -29,8 +29,9 @@ define([
                     return;
                 }
 
-                this._templateData[ templateParameter.name ] = templateParameter.current.value;
+                _templateData[ templateParameter.name ] = templateParameter.current.value;
             });
+            this._templateData = _templateData;
         },
 
         templateOptionSelected : function(option) {
@@ -40,6 +41,7 @@ define([
 
         addTemplateParameter : function( templateParameter ) {
             this.templateParameters.push( templateParameter );
+            this._updateTemplateData();
         },
 
         applyTemplateToTarget : function(target) {

+ 2 - 2
src/test/specs/filterSrv-specs.js

@@ -21,12 +21,12 @@ define([
 
     describe('init', function() {
       beforeEach(function() {
-        _filterSrv.add({ name: 'test', current: { value: 'oogle' } });
         _filterSrv.init();
+        _filterSrv.addTemplateParameter({ name: 'test', current: { value: 'oogle' } });
       });
 
       it('should initialize template data', function() {
-        var target = _filterSrv.applyFilterToTarget('this.[[test]].filters');
+        var target = _filterSrv.applyTemplateToTarget('this.[[test]].filters');
         expect(target).to.be('this.oogle.filters');
       });
     });