I am trying to test a controller that gets the router permission of an object:
app.js :
... .when('/confirm', { templateUrl: 'views/confirm.html', controller: 'ConfirmCtrl', resolve: { order: function(Order) { return Order.current; } } }) ...
ConfirmCtrl.js :
angular.module('angularGeolocationApp').controller('ConfirmCtrl', function($scope, order, ...) { $scope.order = order ... });
My test is as follows:
'use strict'; describe('Controller: ConfirmCtrl', function () {
However, the first wait fails:
PhantomJS 1.9.2 (Mac OS X) Controller: ConfirmCtrl should get an order object FAILED TypeError: Attempted to assign to readonly property. at workFn (/Users/jviotti/Projects/Temporal/angular/angular-geolocation/app/bower_components/angular-mocks/angular-mocks.js:2107) Expected false to be truthy.
My assumption is that when I test an isolated controller, the router has no changes to run the enable function and assign the correct value.
Is there any way to make fun of this order dependency?
I know that I can get rid of permission files and insert order and create an instance of $scope.order before Order.current in the controller itself, but I would like to support the resolve approach.
angularjs unit-testing karma-runner
jviotti
source share