| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import {describe, it, expect} from 'test/lib/common';
- import {AdhocVariable} from '../adhoc_variable';
- describe('AdhocVariable', function() {
- describe('when serializing to url', function() {
- it('should set return key value and op seperated by pipe', function() {
- var variable = new AdhocVariable({
- filters: [
- {key: 'key1', operator: '=', value: 'value1'},
- {key: 'key2', operator: '!=', value: 'value2'},
- {key: 'key3', operator: '=', value: 'value3a|value3b|value3c'},
- ]
- });
- var urlValue = variable.getValueForUrl();
- expect(urlValue).to.eql(["key1|=|value1", "key2|!=|value2", "key3|=|value3a__gfp__value3b__gfp__value3c"]);
- });
- });
- describe('when deserializing from url', function() {
- it('should restore filters', function() {
- var variable = new AdhocVariable({});
- variable.setValueFromUrl(["key1|=|value1", "key2|!=|value2", "key3|=|value3a__gfp__value3b__gfp__value3c"]);
- expect(variable.filters[0].key).to.be('key1');
- expect(variable.filters[0].operator).to.be('=');
- expect(variable.filters[0].value).to.be('value1');
- expect(variable.filters[1].key).to.be('key2');
- expect(variable.filters[1].operator).to.be('!=');
- expect(variable.filters[1].value).to.be('value2');
- expect(variable.filters[2].key).to.be('key3');
- expect(variable.filters[2].operator).to.be('=');
- expect(variable.filters[2].value).to.be('value3a|value3b|value3c');
- });
- });
- });
|