SmartIT_Extensions/BMC/smart-it-full/test/app/common/utils/parse-query-string.spec.js

40 lines
948 B
JavaScript

describe('utility function: parse-query-string', function () {
'use strict';
var qsp;
beforeEach(function () {
module('myitsmApp');
});
describe('Testing of basic functionallity', function () {
beforeEach(function () {
inject(['queryStringParser', function (queryStringParser) {
qsp = queryStringParser;
}]);
});
it('query string should be parsed correctly', function () {
var queryParamas = qsp.parse('debug=1&debugTopic=expressions')
expect(queryParamas.debug).toEqual('1');
expect(queryParamas.debugTopic).toEqual('expressions');
});
it('should throw if not string provided', function() {
expect(function(){
qsp.parse({});
}).toThrowError('Not a string');
});
it('query string should be build correctly', function () {
var queryParamas = {
debug: 1,
debugTopic: 'expressions'
}
expect(qsp.build(queryParamas)).toEqual('debug=1&debugTopic=expressions');
});
});
});