mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Partial fix for #10 , the lexer & parser can now handle curly brace, but target editor needs to be updated to support selecting multiple segment nodes
This commit is contained in:
@@ -60,7 +60,7 @@ define([
|
||||
|
||||
it('should return function categories', function() {
|
||||
var catIndex = gfunc.getCategories();
|
||||
expect(catIndex.Special.length).to.equal(7);
|
||||
expect(catIndex.Special.length).to.equal(8);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -21,6 +21,16 @@ define([
|
||||
expect(tokens[4].value).to.be('se1-server-*');
|
||||
});
|
||||
|
||||
it('should tokenize metric expression with curly braces', function() {
|
||||
var lexer = new Lexer('metric.se1-{first, second}.count');
|
||||
var tokens = lexer.tokenize();
|
||||
expect(tokens.length).to.be(10);
|
||||
expect(tokens[3].type).to.be('{');
|
||||
expect(tokens[4].value).to.be('first');
|
||||
expect(tokens[5].value).to.be(',');
|
||||
expect(tokens[6].value).to.be('second');
|
||||
});
|
||||
|
||||
|
||||
it('should tokenize functions and args', function() {
|
||||
var lexer = new Lexer("sum(metric.test, 12, 'test')");
|
||||
|
||||
@@ -13,6 +13,24 @@ define([
|
||||
expect(rootNode.segments[0].value).to.be('metric');
|
||||
});
|
||||
|
||||
it('simple metric expression with curly braces', function() {
|
||||
var parser = new Parser('metric.se1-{count, max}');
|
||||
var rootNode = parser.getAst();
|
||||
|
||||
expect(rootNode.type).to.be('metric');
|
||||
expect(rootNode.segments.length).to.be(2);
|
||||
expect(rootNode.segments[1].value).to.be('se1-{count,max}');
|
||||
});
|
||||
|
||||
it('simple metric expression with curly braces at start of segment and with post chars', function() {
|
||||
var parser = new Parser('metric.{count, max}-something.count');
|
||||
var rootNode = parser.getAst();
|
||||
|
||||
expect(rootNode.type).to.be('metric');
|
||||
expect(rootNode.segments.length).to.be(3);
|
||||
expect(rootNode.segments[1].value).to.be('{count,max}-something');
|
||||
});
|
||||
|
||||
it('simple function', function() {
|
||||
var parser = new Parser('sum(test)');
|
||||
var rootNode = parser.getAst();
|
||||
|
||||
Reference in New Issue
Block a user