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

62 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

2014-02-10 13:09:31 +02:00
'use strict';
(function () {
describe('HeaderController', function () {
// 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));
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 as vm', {
2015-07-28 17:52:03 -06:00
$scope: scope
});
}));
it('should expose the authentication service', function () {
expect(scope.vm.authentication).toBe(Authentication);
2015-07-28 17:52:03 -06:00
});
it('should default menu to collapsed', function () {
expect(scope.vm.isCollapsed).toBeFalsy();
2015-07-28 17:52:03 -06:00
});
describe('when toggleCollapsibleMenu', function () {
2015-07-28 17:52:03 -06:00
var defaultCollapse;
beforeEach(function () {
defaultCollapse = scope.vm.isCollapsed;
scope.vm.isCollapsed = !scope.vm.isCollapsed;
2015-07-28 17:52:03 -06:00
});
it('should toggle isCollapsed to non default value', function () {
expect(scope.vm.isCollapsed).not.toBe(defaultCollapse);
2015-07-28 17:52:03 -06:00
});
it('should then toggle isCollapsed back to default value', function () {
scope.vm.isCollapsed = !scope.vm.isCollapsed;
expect(scope.vm.isCollapsed).toBe(defaultCollapse);
2015-07-28 17:52:03 -06:00
});
});
describe('when view state changes', function () {
beforeEach(function () {
scope.vm.isCollapsed = true;
2015-07-28 17:52:03 -06:00
scope.$broadcast('$stateChangeSuccess');
});
it('should set isCollapsed to false', function () {
expect(scope.vm.isCollapsed).toBeFalsy();
2015-07-28 17:52:03 -06:00
});
});
});
}());