Files
meanTorrent/modules/core/tests/client/header.client.controller.tests.js

65 lines
1.8 KiB
JavaScript
Raw Normal View History

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