aliasByNode support for second node param, Closes #167

This commit is contained in:
Torkel Ödegaard
2014-03-24 09:57:03 +01:00
parent 2e1e7462dc
commit 6f9c2211fa
3 changed files with 108 additions and 16 deletions

View File

@@ -57,12 +57,47 @@ define([
});
describe('when requesting function categories', function() {
it('should return function categories', function() {
var catIndex = gfunc.getCategories();
expect(catIndex.Special.length).to.be.greaterThan(8);
});
});
describe('when updating func param', function() {
it('should update param value and update text representation', function() {
var func = gfunc.createFuncInstance('summarize');
func.updateParam('1h', 0);
expect(func.params[0]).to.be('1h');
expect(func.text).to.be('summarize(1h, sum)');
});
});
describe('when updating func param with optional second parameter', function() {
it('should update value and text', function() {
var func = gfunc.createFuncInstance('aliasByNode');
func.updateParam('1', 0);
expect(func.params[0]).to.be(1);
});
it('should slit text and put value in second param', function() {
var func = gfunc.createFuncInstance('aliasByNode');
func.updateParam('4,-5', 0);
expect(func.params[0]).to.be(4);
expect(func.params[1]).to.be(-5);
expect(func.text).to.be('aliasByNode(4, -5)');
});
it('should remove second param when empty string is set', function() {
var func = gfunc.createFuncInstance('aliasByNode');
func.updateParam('4,-5', 0);
func.updateParam('', 1);
expect(func.params[0]).to.be(4);
expect(func.params[1]).to.be(undefined);
expect(func.text).to.be('aliasByNode(4)');
});
});
});