|
@@ -31,12 +31,40 @@ describe('templateSrv', function() {
|
|
|
expect(target).toBe('this.mupp.filters');
|
|
expect(target).toBe('this.mupp.filters');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ it('should replace ${test} with scoped value', function() {
|
|
|
|
|
+ var target = _templateSrv.replace('this.${test}.filters', {
|
|
|
|
|
+ test: { value: 'mupp', text: 'asd' },
|
|
|
|
|
+ });
|
|
|
|
|
+ expect(target).toBe('this.mupp.filters');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should replace ${test:glob} with scoped value', function() {
|
|
|
|
|
+ var target = _templateSrv.replace('this.${test:glob}.filters', {
|
|
|
|
|
+ test: { value: 'mupp', text: 'asd' },
|
|
|
|
|
+ });
|
|
|
|
|
+ expect(target).toBe('this.mupp.filters');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
it('should replace $test with scoped text', function() {
|
|
it('should replace $test with scoped text', function() {
|
|
|
var target = _templateSrv.replaceWithText('this.$test.filters', {
|
|
var target = _templateSrv.replaceWithText('this.$test.filters', {
|
|
|
test: { value: 'mupp', text: 'asd' },
|
|
test: { value: 'mupp', text: 'asd' },
|
|
|
});
|
|
});
|
|
|
expect(target).toBe('this.asd.filters');
|
|
expect(target).toBe('this.asd.filters');
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ it('should replace ${test} with scoped text', function() {
|
|
|
|
|
+ var target = _templateSrv.replaceWithText('this.${test}.filters', {
|
|
|
|
|
+ test: { value: 'mupp', text: 'asd' },
|
|
|
|
|
+ });
|
|
|
|
|
+ expect(target).toBe('this.asd.filters');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should replace ${test:glob} with scoped text', function() {
|
|
|
|
|
+ var target = _templateSrv.replaceWithText('this.${test:glob}.filters', {
|
|
|
|
|
+ test: { value: 'mupp', text: 'asd' },
|
|
|
|
|
+ });
|
|
|
|
|
+ expect(target).toBe('this.asd.filters');
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
describe('getAdhocFilters', function() {
|
|
describe('getAdhocFilters', function() {
|
|
@@ -79,18 +107,34 @@ describe('templateSrv', function() {
|
|
|
]);
|
|
]);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+
|
|
|
it('should replace $test with globbed value', function() {
|
|
it('should replace $test with globbed value', function() {
|
|
|
var target = _templateSrv.replace('this.$test.filters', {}, 'glob');
|
|
var target = _templateSrv.replace('this.$test.filters', {}, 'glob');
|
|
|
expect(target).toBe('this.{value1,value2}.filters');
|
|
expect(target).toBe('this.{value1,value2}.filters');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ it('should replace ${test} with globbed value', function() {
|
|
|
|
|
+ var target = _templateSrv.replace('this.${test}.filters', {}, 'glob');
|
|
|
|
|
+ expect(target).toBe('this.{value1,value2}.filters');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should replace ${test:glob} with globbed value', function() {
|
|
|
|
|
+ var target = _templateSrv.replace('this.${test:glob}.filters', {});
|
|
|
|
|
+ expect(target).toBe('this.{value1,value2}.filters');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
it('should replace $test with piped value', function() {
|
|
it('should replace $test with piped value', function() {
|
|
|
var target = _templateSrv.replace('this=$test', {}, 'pipe');
|
|
var target = _templateSrv.replace('this=$test', {}, 'pipe');
|
|
|
expect(target).toBe('this=value1|value2');
|
|
expect(target).toBe('this=value1|value2');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- it('should replace $test with piped value', function() {
|
|
|
|
|
- var target = _templateSrv.replace('this=$test', {}, 'pipe');
|
|
|
|
|
|
|
+ it('should replace ${test} with piped value', function() {
|
|
|
|
|
+ var target = _templateSrv.replace('this=${test}', {}, 'pipe');
|
|
|
|
|
+ expect(target).toBe('this=value1|value2');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should replace ${test:pipe} with piped value', function() {
|
|
|
|
|
+ var target = _templateSrv.replace('this=${test:pipe}', {});
|
|
|
expect(target).toBe('this=value1|value2');
|
|
expect(target).toBe('this=value1|value2');
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
@@ -111,6 +155,16 @@ describe('templateSrv', function() {
|
|
|
var target = _templateSrv.replace('this.$test.filters', {}, 'glob');
|
|
var target = _templateSrv.replace('this.$test.filters', {}, 'glob');
|
|
|
expect(target).toBe('this.{value1,value2}.filters');
|
|
expect(target).toBe('this.{value1,value2}.filters');
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ it('should replace ${test} with formatted all value', function() {
|
|
|
|
|
+ var target = _templateSrv.replace('this.${test}.filters', {}, 'glob');
|
|
|
|
|
+ expect(target).toBe('this.{value1,value2}.filters');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should replace ${test:glob} with formatted all value', function() {
|
|
|
|
|
+ var target = _templateSrv.replace('this.${test:glob}.filters', {});
|
|
|
|
|
+ expect(target).toBe('this.{value1,value2}.filters');
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
describe('variable with all option and custom value', function() {
|
|
describe('variable with all option and custom value', function() {
|
|
@@ -131,6 +185,16 @@ describe('templateSrv', function() {
|
|
|
expect(target).toBe('this.*.filters');
|
|
expect(target).toBe('this.*.filters');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ it('should replace ${test} with formatted all value', function() {
|
|
|
|
|
+ var target = _templateSrv.replace('this.${test}.filters', {}, 'glob');
|
|
|
|
|
+ expect(target).toBe('this.*.filters');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should replace ${test:glob} with formatted all value', function() {
|
|
|
|
|
+ var target = _templateSrv.replace('this.${test:glob}.filters', {});
|
|
|
|
|
+ expect(target).toBe('this.*.filters');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
it('should not escape custom all value', function() {
|
|
it('should not escape custom all value', function() {
|
|
|
var target = _templateSrv.replace('this.$test', {}, 'regex');
|
|
var target = _templateSrv.replace('this.$test', {}, 'regex');
|
|
|
expect(target).toBe('this.*');
|
|
expect(target).toBe('this.*');
|
|
@@ -143,6 +207,18 @@ describe('templateSrv', function() {
|
|
|
var target = _templateSrv.replace('this:$test', {}, 'lucene');
|
|
var target = _templateSrv.replace('this:$test', {}, 'lucene');
|
|
|
expect(target).toBe('this:value\\/4');
|
|
expect(target).toBe('this:value\\/4');
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ it('should properly escape ${test} with lucene escape sequences', function() {
|
|
|
|
|
+ initTemplateSrv([{ type: 'query', name: 'test', current: { value: 'value/4' } }]);
|
|
|
|
|
+ var target = _templateSrv.replace('this:${test}', {}, 'lucene');
|
|
|
|
|
+ expect(target).toBe('this:value\\/4');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should properly escape ${test:lucene} with lucene escape sequences', function() {
|
|
|
|
|
+ initTemplateSrv([{ type: 'query', name: 'test', current: { value: 'value/4' } }]);
|
|
|
|
|
+ var target = _templateSrv.replace('this:${test:lucene}', {});
|
|
|
|
|
+ expect(target).toBe('this:value\\/4');
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
describe('format variable to string values', function() {
|
|
describe('format variable to string values', function() {
|