Skip to content

Commit

Permalink
chore(test): move beforeEach block into a describe block so it's not …
Browse files Browse the repository at this point in the history
…executed globally
  • Loading branch information
christopherthielen committed Jan 5, 2017
1 parent f07b369 commit e659227
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions test/urlMatcherFactorySpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ var router: UIRouter;
var $umf: UrlMatcherFactory;
var $location: LocationServices;

beforeEach(function() {
function init() {
router = new UIRouter();
router.plugin(TestingPlugin);
$umf = router.urlMatcherFactory;
let locationPlugin = router.getPlugin('vanilla.memoryLocation') as LocationPlugin;
$location = locationPlugin.service;
});
}

describe("UrlMatcher", function () {
beforeEach(init);

describe("provider", function () {

Expand Down Expand Up @@ -510,6 +511,8 @@ describe("UrlMatcher", function () {
});

describe("urlMatcherFactoryProvider", function () {
beforeEach(init);

describe(".type()", function () {
var m;
beforeEach(function() {
Expand All @@ -535,6 +538,7 @@ describe("urlMatcherFactoryProvider", function () {
});

describe("urlMatcherFactory", function () {
beforeEach(init);

it("compiles patterns", function () {
var matcher = $umf.compile('/hello/world');
Expand Down
12 changes: 6 additions & 6 deletions test/urlRouterSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,21 @@ describe("UrlRouter", function () {

describe("location updates", function() {
it('can push location changes', function () {
spyOn(router.locationService, "url");
spyOn(router.urlService, "url");
urlRouter.push(matcher("/hello/:name"), { name: "world" });
expect(router.locationService.url).toHaveBeenCalledWith("/hello/world", undefined);
expect(router.urlService.url).toHaveBeenCalledWith("/hello/world", undefined);
});

it('can push a replacement location', function () {
spyOn(router.locationService, "url");
spyOn(router.urlService, "url");
urlRouter.push(matcher("/hello/:name"), { name: "world" }, { replace: true });
expect(router.locationService.url).toHaveBeenCalledWith("/hello/world", true);
expect(router.urlService.url).toHaveBeenCalledWith("/hello/world", true);
});

it('can push location changes with no parameters', function () {
spyOn(router.locationService, "url");
spyOn(router.urlService, "url");
urlRouter.push(urlMatcherFactory.compile("/hello/:name", { params: { name: "" } }));
expect(router.locationService.url).toHaveBeenCalledWith("/hello/", undefined);
expect(router.urlService.url).toHaveBeenCalledWith("/hello/", undefined);
});

it('can push location changes that include a #fragment', function () {
Expand Down

0 comments on commit e659227

Please sign in to comment.