2014-02-10 13:09:31 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
2015-07-25 16:53:11 -04:00
|
|
|
(function () {
|
|
|
|
|
describe('HeaderController', function () {
|
2015-12-10 20:31:51 +01:00
|
|
|
// Initialize global variables
|
2015-07-28 17:52:03 -06:00
|
|
|
var scope,
|
|
|
|
|
HeaderController,
|
|
|
|
|
$state,
|
|
|
|
|
Authentication;
|
|
|
|
|
|
|
|
|
|
// Load the main application module
|
|
|
|
|
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
|
|
|
|
|
2015-07-25 16:53:11 -04:00
|
|
|
beforeEach(inject(function ($controller, $rootScope, _$state_, _Authentication_) {
|
2015-07-28 17:52:03 -06:00
|
|
|
scope = $rootScope.$new();
|
|
|
|
|
$state = _$state_;
|
|
|
|
|
Authentication = _Authentication_;
|
|
|
|
|
|
2016-02-11 00:20:17 -05:00
|
|
|
HeaderController = $controller('HeaderController as vm', {
|
2015-07-28 17:52:03 -06:00
|
|
|
$scope: scope
|
|
|
|
|
});
|
|
|
|
|
}));
|
|
|
|
|
|
2015-07-25 16:53:11 -04:00
|
|
|
it('should expose the authentication service', function () {
|
2016-02-11 00:20:17 -05:00
|
|
|
expect(scope.vm.authentication).toBe(Authentication);
|
2015-07-28 17:52:03 -06:00
|
|
|
});
|
|
|
|
|
|
2015-07-25 16:53:11 -04:00
|
|
|
it('should default menu to collapsed', function () {
|
2016-02-11 00:20:17 -05:00
|
|
|
expect(scope.vm.isCollapsed).toBeFalsy();
|
2015-07-28 17:52:03 -06:00
|
|
|
});
|
|
|
|
|
|
2015-07-25 16:53:11 -04:00
|
|
|
describe('when toggleCollapsibleMenu', function () {
|
2015-07-28 17:52:03 -06:00
|
|
|
var defaultCollapse;
|
2015-07-25 16:53:11 -04:00
|
|
|
beforeEach(function () {
|
2016-02-11 00:20:17 -05:00
|
|
|
defaultCollapse = scope.vm.isCollapsed;
|
|
|
|
|
|
|
|
|
|
scope.vm.isCollapsed = !scope.vm.isCollapsed;
|
2015-07-28 17:52:03 -06:00
|
|
|
});
|
|
|
|
|
|
2015-07-25 16:53:11 -04:00
|
|
|
it('should toggle isCollapsed to non default value', function () {
|
2016-02-11 00:20:17 -05:00
|
|
|
expect(scope.vm.isCollapsed).not.toBe(defaultCollapse);
|
2015-07-28 17:52:03 -06:00
|
|
|
});
|
|
|
|
|
|
2015-07-25 16:53:11 -04:00
|
|
|
it('should then toggle isCollapsed back to default value', function () {
|
2016-02-11 00:20:17 -05:00
|
|
|
scope.vm.isCollapsed = !scope.vm.isCollapsed;
|
|
|
|
|
expect(scope.vm.isCollapsed).toBe(defaultCollapse);
|
2015-07-28 17:52:03 -06:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-07-25 16:53:11 -04:00
|
|
|
describe('when view state changes', function () {
|
|
|
|
|
beforeEach(function () {
|
2016-02-11 00:20:17 -05:00
|
|
|
scope.vm.isCollapsed = true;
|
2015-07-28 17:52:03 -06:00
|
|
|
scope.$broadcast('$stateChangeSuccess');
|
|
|
|
|
});
|
|
|
|
|
|
2015-07-25 16:53:11 -04:00
|
|
|
it('should set isCollapsed to false', function () {
|
2016-02-11 00:20:17 -05:00
|
|
|
expect(scope.vm.isCollapsed).toBeFalsy();
|
2015-07-28 17:52:03 -06:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
2015-12-10 20:31:51 +01:00
|
|
|
}());
|