diff --git a/test/spec/directives/close-menu.directive.js b/test/spec/directives/close-menu.directive.js index 7cf41d571c..3c50b16cc6 100644 --- a/test/spec/directives/close-menu.directive.js +++ b/test/spec/directives/close-menu.directive.js @@ -1,32 +1,25 @@ 'use strict'; describe('closeMenu Directive', function() { - var element, menuElement, scope, ctrl; + var menuElement, scope; beforeEach(module('habitrpg')); - beforeEach(inject(function($rootScope, $compile, $controller) { + beforeEach(inject(function($rootScope, $compile) { scope = $rootScope.$new(); - ctrl = $controller('MenuCtrl', {$scope: scope}); + var element = ''; - element = ''; - - element = $compile(element)(scope); menuElement = $compile(element)(scope); scope.$digest(); })); it('closes a connected menu when element is clicked', function() { - inject(function($timeout) { - var clickSpy = sandbox.spy(); + scope._expandedMenu = 'mobile'; + menuElement.appendTo(document.body); - element.appendTo(document.body); - element.on('click', clickSpy); - element.triggerHandler('click'); + menuElement.triggerHandler('click'); - expect(scope._expandedMenu).to.equal(null) - expect(clickSpy).to.have.been.called; - }); + expect(scope._expandedMenu).to.eql(null) }); }); diff --git a/test/spec/directives/expand-menu.directive.js b/test/spec/directives/expand-menu.directive.js index 9c53149486..f73de77c5b 100644 --- a/test/spec/directives/expand-menu.directive.js +++ b/test/spec/directives/expand-menu.directive.js @@ -1,32 +1,34 @@ 'use strict'; describe('expandMenu Directive', function() { - var element, menuElement, scope, ctrl, elm; + var menuElement, scope; beforeEach(module('habitrpg')); - beforeEach(inject(function($rootScope, $compile, $controller) { + beforeEach(inject(function($rootScope, $compile) { scope = $rootScope.$new(); - ctrl = $controller('MenuCtrl', {$scope: scope}); + var element = ''; - element = ''; - - element = $compile(element)(scope); menuElement = $compile(element)(scope); scope.$digest(); })); it('expands a connected menu when element is clicked', function() { - inject(function($timeout) { - var clickSpy = sandbox.spy(); + expect(scope._expandedMenu).to.not.exist; + menuElement.appendTo(document.body); - element.appendTo(document.body); + menuElement.triggerHandler('click'); - element.on('click', clickSpy); - element.triggerHandler('click'); + expect(scope._expandedMenu).to.eql('mobile') + }); - expect(clickSpy).to.have.been.called; - }); + it('closes a connected menu when it is already open', function() { + scope._expandedMenu = 'mobile'; + menuElement.appendTo(document.body); + + menuElement.triggerHandler('click'); + + expect(scope._expandedMenu).to.eql(null) }); });