2016-09-19 08:15:15 -05:00
|
|
|
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
|
|
|
|
|
|
|
|
import {QueryVariable} from '../query_variable';
|
|
|
|
|
|
|
|
describe('QueryVariable', function() {
|
|
|
|
|
|
|
|
describe('when creating from model', function() {
|
|
|
|
|
|
|
|
it('should set defaults', function() {
|
|
|
|
var variable = new QueryVariable({}, null, null, null, null);
|
|
|
|
expect(variable.datasource).to.be(null);
|
|
|
|
expect(variable.refresh).to.be(0);
|
2016-09-19 10:03:29 -05:00
|
|
|
expect(variable.sort).to.be(0);
|
2016-09-19 08:15:15 -05:00
|
|
|
expect(variable.name).to.be('');
|
|
|
|
expect(variable.hide).to.be(0);
|
|
|
|
expect(variable.options.length).to.be(0);
|
|
|
|
expect(variable.multi).to.be(false);
|
|
|
|
expect(variable.includeAll).to.be(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('get model should copy changes back to model', () => {
|
|
|
|
var variable = new QueryVariable({}, null, null, null, null);
|
|
|
|
variable.options = [{text: 'test'}];
|
|
|
|
variable.datasource = 'google';
|
|
|
|
variable.regex = 'asd';
|
|
|
|
variable.sort = 50;
|
|
|
|
|
2016-11-17 04:28:33 -06:00
|
|
|
var model = variable.getSaveModel();
|
2016-09-19 08:15:15 -05:00
|
|
|
expect(model.options.length).to.be(1);
|
|
|
|
expect(model.options[0].text).to.be('test');
|
|
|
|
expect(model.datasource).to.be('google');
|
|
|
|
expect(model.regex).to.be('asd');
|
|
|
|
expect(model.sort).to.be(50);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|