Files
CloudBudget-AngularJS/test/global.controller.spec.js
2015-10-09 13:58:16 +00:00

57 lines
1.9 KiB
JavaScript

describe('GlobalController', function() {
var $location,
$rootScope,
$scope,
createController,
DEFAULT_ACCOUNTS = [
{
"_id": "560a84058812ad8d0ff200ee",
"name": "foo",
"reference": "baz",
"user_id": "55b78934d2a706265ea28e9c"
}, {
"_id": "560a7ad08812ad8d0ff20068",
"name": "bar",
"user_id": "55b78934d2a706265ea28e9c"
}
];
beforeEach(module('cloudbudget'));
beforeEach(inject(function ( _$rootScope_, $controller, _$location_) {
$location = _$location_;
$rootScope = _$rootScope_;
$rootScope.globals = {
user: true
};
$scope = _$rootScope_.$new();
createController = function() {
return $controller('GlobalController', {
'$scope': $scope,
'$location': $location,
'$rootScope': $rootScope
});
};
}));
it('should init successfully', inject(function($location, $rootScope) {
var globalController = createController();
globalController.current_account = '560a84058812ad8d0ff200ee';
globalController.change_account();
$location.path().should.be.equal('/account/560a84058812ad8d0ff200ee')
}));
it('should change successfully', inject(function($location, $rootScope) {
var globalController = createController();
globalController.current_account = '560a84058812ad8d0ff200ee';
globalController.change_account();
$rootScope.current_account = '560a7ad08812ad8d0ff20068';
$rootScope.$digest();
globalController.change_account();
$rootScope.$digest();
$location.path().should.be.equal('/account/560a7ad08812ad8d0ff20068')
}));
});