|
|
@@ -2,11 +2,11 @@ import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/co
|
|
|
|
|
|
import {QueryVariable} from '../query_variable';
|
|
|
|
|
|
-describe('QueryVariable', function() {
|
|
|
+describe('QueryVariable', () => {
|
|
|
|
|
|
- describe('when creating from model', function() {
|
|
|
+ describe('when creating from model', () => {
|
|
|
|
|
|
- it('should set defaults', function() {
|
|
|
+ it('should set defaults', () => {
|
|
|
var variable = new QueryVariable({}, null, null, null, null);
|
|
|
expect(variable.datasource).to.be(null);
|
|
|
expect(variable.refresh).to.be(0);
|
|
|
@@ -42,5 +42,38 @@ describe('QueryVariable', function() {
|
|
|
expect(model.options.length).to.be(0);
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ describe('can convert and sort metric names',() => {
|
|
|
+ var variable = new QueryVariable({}, null, null, null, null);
|
|
|
+ variable.sort = 51;
|
|
|
+
|
|
|
+ describe('can sort a mixed array of metric variables', () => {
|
|
|
+ var input = [
|
|
|
+ {text: '0', value: '0'},
|
|
|
+ {text: '1', value: '1'},
|
|
|
+ {text: '', value: ''},
|
|
|
+ {text: null, value: 3},
|
|
|
+ {text: undefined, value: 4},
|
|
|
+ {text: '5', value: null},
|
|
|
+ {text: '6', value: undefined},
|
|
|
+ {text: null, value: '3'},
|
|
|
+ {text: undefined, value: '4'},
|
|
|
+ {text: 5, value: null},
|
|
|
+ {text: 6, value: undefined},
|
|
|
+ ];
|
|
|
+
|
|
|
+ var result = variable.metricNamesToVariableValues(input);
|
|
|
+
|
|
|
+ it('should return in same order', () => {
|
|
|
+ expect(result[0].text).to.be('0');
|
|
|
+ expect(result[1].text).to.be('1');
|
|
|
+ expect(result[2].text).to.be('');
|
|
|
+ expect(result[3].text).to.be('3');
|
|
|
+ expect(result[4].text).to.be('4');
|
|
|
+ expect(result[5].text).to.be('5');
|
|
|
+ expect(result[6].text).to.be('6');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
|