uri.js 855 B

12345678910111213141516171819202122232425262728293031323334353637
  1. describe('UriService', function() {
  2. let $service;
  3. // Ignoring page reload request
  4. beforeAll(() => window.onbeforeunload = () => null);
  5. beforeEach(function() {
  6. module('3ema.services');
  7. // Inject the service
  8. inject(function(UriService) {
  9. $service = UriService;
  10. });
  11. });
  12. it('parses query parameters', () => {
  13. const parsed = $service.parseQueryParams('foo=bar&baz=a%20b%20c');
  14. expect(parsed).toEqual({
  15. 'foo': 'bar',
  16. 'baz': 'a b c',
  17. });
  18. });
  19. it('parses empty query parameters', () => {
  20. const parsed = $service.parseQueryParams('');
  21. expect(parsed).toEqual({});
  22. });
  23. it('ignores invalid params', () => {
  24. const parsed = $service.parseQueryParams(7);
  25. expect(parsed).toEqual(null);
  26. });
  27. });