add tests for the rison filters

This commit is contained in:
Joe Fleming 2014-09-03 17:05:27 -07:00
parent c75ade4909
commit 5662396d78
2 changed files with 59 additions and 0 deletions

View file

@ -71,6 +71,7 @@
'specs/filters/field_type',
'specs/filters/uriescape',
'specs/filters/moment',
'specs/filters/rison',
'specs/filters/short_dots',
'specs/filters/start_from',
'specs/services/storage',

View file

@ -0,0 +1,58 @@
define(function (require) {
var angular = require('angular');
// Load the kibana app dependencies.
require('angular-route');
// Load kibana and its applications
require('index');
require('apps/discover/index');
var rison;
var risonDecode;
var init = function (expandable) {
// Load the application
module('kibana');
// Create the scope
inject(function ($filter) {
rison = $filter('rison');
risonDecode = $filter('risonDecode');
});
};
describe('rison filters', function () {
var testObj = {
time: {
from: 'now-15m',
to: 'now'
}
};
var testRison = '(time:(from:now-15m,to:now))';
beforeEach(function () {
init();
});
describe('rison', function () {
it('should have the filter', function () {
expect(rison).to.not.be(null);
});
it('should rison encode data', function () {
expect(rison(testObj)).to.be(testRison);
});
});
describe('risonDecode', function () {
it('should have the filter', function () {
expect(risonDecode).to.not.be(null);
});
it('should decode rison data', function () {
expect(risonDecode(testRison)).to.eql(testObj);
});
});
});
});