Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit 4a72024

Browse files
test(urlMatcherFactory): convert test to typescript
1 parent 46b8b2b commit 4a72024

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

test/urlMatcherFactorySpec.js renamed to test/urlMatcherFactorySpec.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
var module = angular.mock.module;
2-
var uiRouter = require("../src/index");
3-
var services = require("@uirouter/core").services;
4-
var Param = uiRouter.Param;
5-
var ParamTypes = uiRouter.ParamTypes;
6-
var UrlMatcher = uiRouter.UrlMatcher;
7-
var prop = uiRouter.prop;
8-
var map = uiRouter.map;
9-
var find = uiRouter.find;
10-
11-
var router;
12-
var $umf;
13-
var $url;
1+
import * as angular from "angular";
2+
import { find, map, prop, UrlMatcher, } from "../src/index";
3+
import { UIRouter, UrlMatcherFactory, UrlService } from '@uirouter/core';
4+
import "./util/matchers";
5+
6+
declare var inject;
7+
8+
var module = angular['mock'].module;
9+
10+
var router: UIRouter;
11+
var $umf: UrlMatcherFactory;
12+
var $url: UrlService;
1413

1514
beforeEach(function() {
1615
var app = angular.module('ui.router.router.test', []);
@@ -148,7 +147,7 @@ describe("UrlMatcher", function () {
148147
err = new Error("Invalid parameter name 'periods.' in pattern '/users/?from&to&periods.'");
149148
expect(function() { $umf.compile('/users/?from&to&periods.'); }).toThrow(err);
150149
});
151-
});
150+
});
152151

153152
describe(".exec()", function() {
154153
it("should capture parameter values", function () {
@@ -166,12 +165,12 @@ describe("UrlMatcher", function () {
166165
var m = $umf.compile('/users/:id/details/{type}/{repeat:[0-9]+}?from&to');
167166
expect(m.exec('/users/123/details/what/thisShouldBeDigits', {})).toBeNull();
168167
});
169-
168+
170169
it("should not use optional regexp for '/'", function () {
171170
var m = $umf.compile('/{language:(?:fr|en|de)}');
172171
expect(m.exec('/', {})).toBeNull();
173172
});
174-
173+
175174
it("should work with empty default value", function () {
176175
var m = $umf.compile('/foo/:str', { params: { str: { value: "" } } });
177176
expect(m.exec('/foo/', {})).toEqual({ str: "" });
@@ -181,7 +180,7 @@ describe("UrlMatcher", function () {
181180
var m = $umf.compile('/foo/{param:(?:foo|bar|)}', { params: { param: { value: "" } } });
182181
expect(m.exec('/foo/', {})).toEqual({ param: "" });
183182
});
184-
183+
185184
it("should treat the URL as already decoded and does not decode it further", function () {
186185
expect($umf.compile('/users/:id').exec('/users/100%25', {})).toEqual({ id: '100%25'});
187186
});

0 commit comments

Comments
 (0)