Skip to content

Commit

Permalink
Fixed failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yehudab committed Oct 2, 2013
1 parent 5d3dbaf commit 2b59a63
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions client/test/unit/app/admin/projects/admin-projects.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,51 @@ describe('admin projects', function () {
params = {
$scope: $scope,
$location: jasmine.createSpyObj('$location', ['path']),
i18nNotifications: jasmine.createSpyObj('i18nNotifications', ['pushForCurrentRoute', 'pushForNextRoute']),
users: [ { $id: function() { return 'X'; }} ],
project: {}
project: { $id: function() { return 'Y'; }}
};
params.users.filter = jasmine.createSpy('filter');
ctrl = $controller('ProjectsEditCtrl', params);
});
it('should call setup a scope objects correctly', function () {
expect($scope.project).toBe(params.project);
expect($scope.users).toBe(params.users);
expect($scope.usersLookup).toEqual({ 'X': params.users[0] });
expect($scope.project.teamMembers).toEqual([]);
});
it('should call $location in onSave', function() {
$scope.onSave();
it('should call $location and display a success message in onSave', function() {
$scope.onSave(params.project);
expect(params.i18nNotifications.pushForNextRoute).toHaveBeenCalled();
expect(params.i18nNotifications.pushForNextRoute.mostRecentCall.args[1]).toBe('success');
expect(params.$location.path).toHaveBeenCalled();
});
it('should set updateError in onError', function() {
it('should display an error message in onError', function() {
$scope.onError();
expect($scope.updateError).toBe(true);
expect(params.i18nNotifications.pushForCurrentRoute).toHaveBeenCalled();
expect(params.i18nNotifications.pushForCurrentRoute.mostRecentCall.args[1]).toBe('error');
});
});

describe('TeamMembersController', function () {
var params, ctrl, users;
beforeEach(function () {
params = { $scope: $scope };
users = [ { $id: function () { return 'X'; }}];
users.filter = jasmine.createSpy('filter');
$scope.users = users;
$scope.project = { $id: function () { return 'Y'; }};
ctrl = $controller('TeamMembersController', params);
});
it('should call filter when getting candidates', function() {
it('should call setup a scope objects correctly', function () {
expect($scope.usersLookup).toEqual({ 'X': users[0] });
expect($scope.project.teamMembers).toEqual([]);
});
it('should call filter when getting candidates', function () {
$scope.productOwnerCandidates();
expect(params.users.filter).toHaveBeenCalled();
expect(users.filter).toHaveBeenCalled();
$scope.scrumMasterCandidates();
expect(params.users.filter).toHaveBeenCalled();
expect(users.filter).toHaveBeenCalled();
$scope.teamMemberCandidates();
expect(params.users.filter).toHaveBeenCalled();
expect(users.filter).toHaveBeenCalled();
});
it('should push items into team members array in addTeamMember only if a team member is selected', function() {
expect($scope.project.teamMembers.length).toBe(0);
Expand All @@ -73,7 +91,7 @@ describe('admin projects', function () {
$scope.project.teamMembers.push(someTeamMember);
$scope.removeTeamMember(someTeamMember);
expect($scope.project.teamMembers.length).toBe(0);

$scope.project.teamMembers.push(someTeamMember);
$scope.removeTeamMember(otherTeamMember);
expect($scope.project.teamMembers.length).toBe(1);
Expand Down

0 comments on commit 2b59a63

Please sign in to comment.