|
|
@ -28,38 +28,37 @@ |
|
|
|
|
|
|
|
|
|
|
|
var expect = chai.expect; |
|
|
|
var expect = chai.expect; |
|
|
|
|
|
|
|
|
|
|
|
describe('Routing', function () { |
|
|
|
describe('Routing', () => { |
|
|
|
var $rootScope, $state, mockState = { |
|
|
|
var $rootScope, $state, mockState = { |
|
|
|
go: function () { |
|
|
|
go: () => {} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
beforeEach(angular.mock.module('openproject', function ($provide) { |
|
|
|
beforeEach(angular.mock.module('openproject', ($provide) => { |
|
|
|
$provide.value('$state', mockState); |
|
|
|
$provide.value('$state', mockState); |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
beforeEach(inject(function (_$rootScope_) { |
|
|
|
beforeEach(inject((_$rootScope_) => { |
|
|
|
$rootScope = _$rootScope_; |
|
|
|
$rootScope = _$rootScope_; |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
describe('when the project id is set', function () { |
|
|
|
describe('when the project id is set', () => { |
|
|
|
var toState, toParams, |
|
|
|
var toState, toParams, |
|
|
|
spy = sinon.spy(mockState, 'go'), |
|
|
|
spy = sinon.spy(mockState, 'go'), |
|
|
|
broadcast = function () { |
|
|
|
broadcast = () => { |
|
|
|
$rootScope.$broadcast('$stateChangeStart', toState, toParams); |
|
|
|
$rootScope.$broadcast('$stateChangeStart', toState, toParams); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
beforeEach(function () { |
|
|
|
beforeEach(() => { |
|
|
|
toState = {name: 'work-packages.list'}; |
|
|
|
toState = {name: 'work-packages.list'}; |
|
|
|
toParams = {projectPath: 'my_project', projects: null}; |
|
|
|
toParams = {projectPath: 'my_project', projects: null}; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('sets the projects path segment to "projects" ', function () { |
|
|
|
it('sets the projects path segment to "projects" ', () => { |
|
|
|
broadcast(); |
|
|
|
broadcast(); |
|
|
|
expect(toParams.projects).to.equal('projects'); |
|
|
|
expect(toParams.projects).to.equal('projects'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('routes to the given state', function () { |
|
|
|
it('routes to the given state', () => { |
|
|
|
broadcast(); |
|
|
|
broadcast(); |
|
|
|
expect(spy.withArgs(toState, toParams).called).to.be.true; |
|
|
|
expect(spy.withArgs(toState, toParams).called).to.be.true; |
|
|
|
}); |
|
|
|
}); |
|
|
|