uri.js 845 B

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