import {
  describe,
  it,
  iit,
  ddescribe,
  expect,
  inject,
  beforeEach,
} from '@angular/core/testing/testing_internal';

import {GeneratedUrl} from '../../../src/rules/route_paths/route_path';
import {RegexRoutePath} from '../../../src/rules/route_paths/regex_route_path';
import {parser, Url} from '../../../src/url_parser';

function emptySerializer(params) {
  return new GeneratedUrl('', {});
}

export function main() {
  describe('RegexRoutePath', () => {

    it('should throw when given an invalid regex',
       () => { expect(() => new RegexRoutePath('[abc', emptySerializer)).toThrowError(); });

    it('should parse a single param using capture groups', () => {
      var rec = new RegexRoutePath('^(.+)$', emptySerializer);
      var url = parser.parse('hello');
      var match = rec.matchUrl(url);
      expect(match.allParams).toEqual({'0': 'hello', '1': 'hello'});
    });

    it('should parse multiple params using capture groups', () => {
      var rec = new RegexRoutePath('^(.+)\\.(.+)$', emptySerializer);
      var url = parser.parse('hello.goodbye');
      var match = rec.matchUrl(url);
      expect(match.allParams).toEqual({'0': 'hello.goodbye', '1': 'hello', '2': 'goodbye'});
    });

    it('should generate a url by calling the provided serializer', () => {
      function serializer(params) 

      var rec = new RegexRoutePath('/a/(.+)/b/(.+)$', serializer);
      var params = {a: 'one', b: 'two'};
      var url = rec.generateUrl(params);
      expect(url.urlPath).toEqual('/a/one/b/two');
    });
  });
}

{
        return new GeneratedUrl(`/a/${params['a']}/b/${params['b']}`, {});
      }