https://github.com/angular/angular
Raw File
Tip revision: 2a236b40666c1714cee35efc42bb059761a24a40 authored by Alex Eagle on 07 March 2018, 22:45:07 UTC
docs: add changelog for 5.2.8
Tip revision: 2a236b4
FirebaseRedirect.spec.ts
import { FirebaseRedirect } from './FirebaseRedirect';

describe('FirebaseRedirect', () => {
  describe('replace', () => {
    it('should return undefined if the redirect does not match the url', () => {
      const redirect = new FirebaseRedirect('/a/b/c', '/x/y/z');
      expect(redirect.replace('/1/2/3')).toBe(undefined);
    });

    it('should return the destination if there is a match', () => {
      const redirect = new FirebaseRedirect('/a/b/c', '/x/y/z');
      expect(redirect.replace('/a/b/c')).toBe('/x/y/z');
    });

    it('should inject name params into the destination', () => {
      const redirect = new FirebaseRedirect('/api/:package/:api-*', '<:package><:api>');
      expect(redirect.replace('/api/common/NgClass-directive')).toEqual('<common><NgClass>');
    });

    it('should inject rest params into the destination', () => {
      const redirect = new FirebaseRedirect('/a/:rest*', '/x/:rest*/y');
      expect(redirect.replace('/a/b/c')).toEqual('/x/b/c/y');
    });

    it('should inject both named and rest parameters into the destination', () => {
      const redirect = new FirebaseRedirect('/:a/:rest*', '/x/:a/y/:rest*/z');
      expect(redirect.replace('/a/b/c')).toEqual('/x/a/y/b/c/z');
    });
  });
});
back to top