You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
describe('TournamentListController',function(){var$rootScope,$controller,createController,tournament,anyFunction,controllerbeforeEach(module('sportAdmin'))beforeEach(inject(function($injector){$rootScope=$injector.get('$rootScope')$controller=$injector.get('$controller')anyFunction=jasmine.any(Function)createController=function(tournament){return$controller('TournamentListController',{'$scope' : $rootScope,'Tournament': tournament,'Alerts': mockAlerts})}}))...describe('TournamentListController#create success',function(){beforeEach(function(){spyOn(mockTournament,'create').and.callThrough()spyOn(mockAlerts,'success').and.callThrough()spyOn(mockAlerts,'error').and.callThrough()controller=createController(mockTournament)tournament={name: "New Tournament",sport_id: 1}controller.create(tournament)})it('should delegate tournament create to the service',function(){expect(mockTournament.create).toHaveBeenCalled()})it('should add the tournament to the list',function(){expect(controller.tournaments.length).toEqual(3)})it('should add the tournament to the top of the list',function(){expect(controller.tournaments[0].name).toEqual(tournament.name)})it('should display the success alert message',function(){expect(mockAlerts.success).toHaveBeenCalledWith('TOURNAMENT.create_success')})})...describe('TournamentListController#delete error',function(){beforeEach(function(){mockTournament.destroy=function(id,success,error){returnerror()}spyOn(mockTournament,'destroy').and.callThrough()controller=createController(mockTournament)tournament=controller.tournaments[0]controller.delete(tournament)})it('should delegate tournament destroy to the service',function(){expect(mockTournament.destroy).toHaveBeenCalledWith(tournament.id,anyFunction,anyFunction)})it('should not remove the tournament when destroy fails',function(){expect(controller.tournaments).toEqual(tournamentFixture())})})})