query_variable_specs.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
  2. import {QueryVariable} from '../query_variable';
  3. describe('QueryVariable', function() {
  4. describe('when creating from model', function() {
  5. it('should set defaults', function() {
  6. var variable = new QueryVariable({}, null, null, null, null);
  7. expect(variable.datasource).to.be(null);
  8. expect(variable.refresh).to.be(0);
  9. expect(variable.sort).to.be(0);
  10. expect(variable.name).to.be('');
  11. expect(variable.hide).to.be(0);
  12. expect(variable.options.length).to.be(0);
  13. expect(variable.multi).to.be(false);
  14. expect(variable.includeAll).to.be(false);
  15. });
  16. it('get model should copy changes back to model', () => {
  17. var variable = new QueryVariable({}, null, null, null, null);
  18. variable.options = [{text: 'test'}];
  19. variable.datasource = 'google';
  20. variable.regex = 'asd';
  21. variable.sort = 50;
  22. var model = variable.getModel();
  23. expect(model.options.length).to.be(1);
  24. expect(model.options[0].text).to.be('test');
  25. expect(model.datasource).to.be('google');
  26. expect(model.regex).to.be('asd');
  27. expect(model.sort).to.be(50);
  28. });
  29. });
  30. });