Created
June 25, 2014 00:07
-
-
Save jakebern/5537b25035966a87bf62 to your computer and use it in GitHub Desktop.
Jasmine Testing - Injecting and testing for state change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.controller('A', function($scope, $state){ | |
$scope.functionA = function(ID){ | |
$state.go('next-state', {number: ID}); | |
}; | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Controller: A', function () { | |
var scope; | |
var A; | |
beforeEach(function () { | |
module('sample'); | |
module('ui.router'); | |
inject(function ($rootScope, $controller,$httpBackend, $state) { | |
scope = $rootScope.$new(); | |
FindDetailCtrl = $controller('A', { | |
$scope: scope, | |
}); | |
$state={ | |
go: function(state, args){} | |
} | |
}); | |
}); | |
it('should change state and include paramter', inject(function($controller, $rootScope, environment, $httpBackend) { | |
spyOn($state, 'go') | |
scope.functionA(25); | |
expect($state.go).toHaveBeenCalledWith('next-state', { number: 25 }); | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment