01/01: add test : check init variables in pollAdminCtrl and voterList behavior
This is an automated email from the git hooks/post-receive script. New commit to branch feature/unitTest in repository pollen. See http://git.chorem.org/pollen.git commit 31b1bf28646473745dd83b0e38b4939a5e131562 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 16 00:52:36 2014 +0200 add test : check init variables in pollAdminCtrl and voterList behavior --- .../src/test/unit/pollControllersTest.js | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/pollen-ui-angular/src/test/unit/pollControllersTest.js b/pollen-ui-angular/src/test/unit/pollControllersTest.js index f4bb7b3..9b69907 100644 --- a/pollen-ui-angular/src/test/unit/pollControllersTest.js +++ b/pollen-ui-angular/src/test/unit/pollControllersTest.js @@ -178,6 +178,87 @@ describe('Test pollCtrl', function () { }); +describe('Test Admin Controller', function () { + beforeEach(module('pollControllers')); + beforeEach(inject(function($controller) { + $scope = {}; + ctrl = $controller('PollAdminCtrl', {$scope: $scope}); + })); + + var $scope = {}; + var ctrl = null; + + it('should load PollAdminCtrl', function() { + expect(ctrl).toBeDefined(); + expect(ctrl).not.toBeNull(); + }); + + it('should set good default tab', function() { + expect($scope.tab).toEqual('edit'); + }); + + it('should be on edited mode', function () { + expect($scope.globalVariables.editMode).toBeTruthy(); + }); + + it('should init list of voterList group', function() { + expect($scope.data.voterList).toBeDefined(); + expect($scope.data.voterList.length).toBeGreaterThan(-1); + }) + + it('should add a new group of voterList', function () { + $scope.addGroup(); + + // check addGroup create is an array + expect($scope.data.voterList.length).toBeGreaterThan(0); + + // check addGroup add one group + var nbVoterList = $scope.data.voterList.length; + $scope.addGroup(); + expect($scope.data.voterList.length).toEqual(nbVoterList + 1); + }); + + it('should new group have name, weight', function () { + // create one voterList group and get one + $scope.addGroup(); + var voterList = $scope.data.voterList[0]; + + expect(voterList.group.name).toBeDefined; + expect(voterList.group.weight).toEqual(1.0); + + }); + + it('should add a new voter in voterList', function () { + // create one voterList and get one + $scope.addGroup(); + + var voterList = $scope.data.voterList[0]; + + // check voterListMembers is an array + $scope.addVoter(0); + expect(voterList.members.length).toBeGreaterThan(0); + + //check add voterListMembers add one member + var nbMember = voterList.members.length; + $scope.addVoter(0); + expect(voterList.members.length).toEqual(nbMember + 1); + }); + + it('should new member have name, email and weight', function () { + $scope.addGroup(); + $scope.addVoter(0); + + // get the first member of the first group + var member = $scope.data.voterList[0].members[0]; + + expect(member.name).toBeDefined(); + expect(member.email).toBeDefined(); + expect(member.weight).toEqual(1.0); + + }); + +}); + describe('load poll controllers', function () { beforeEach(module('pollControllers')); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm