Restructure test
This commit is contained in:
@@ -1,41 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
describe('closeMenu Directive', function() {
|
||||
var menuElement, menuElementWithChild, menuElementChild, scope;
|
||||
var scope;
|
||||
|
||||
beforeEach(module('habitrpg'));
|
||||
|
||||
beforeEach(inject(function($rootScope, $compile) {
|
||||
beforeEach(inject(function($rootScope) {
|
||||
scope = $rootScope.$new();
|
||||
|
||||
var element = '<a data-close-menu menu="mobile">';
|
||||
var elementWithChild = '<li></li>';
|
||||
var elementChild = '<a data-close-menu></a>';
|
||||
|
||||
menuElement = $compile(element)(scope);
|
||||
menuElementWithChild = $compile(elementWithChild)(scope);
|
||||
menuElementChild = $compile(elementChild)(scope);
|
||||
scope.$digest();
|
||||
}));
|
||||
|
||||
it('closes a connected menu when element is clicked', function() {
|
||||
scope._expandedMenu = {};
|
||||
scope._expandedMenu.menu = 'mobile';
|
||||
menuElement.appendTo(document.body);
|
||||
it('closes a connected menu when element is clicked', inject(function($compile) {
|
||||
var menuElement = $compile('<a data-close-menu menu="mobile">')(scope);
|
||||
scope._expandedMenu = { menu: 'mobile' };
|
||||
|
||||
menuElement.appendTo(document.body);
|
||||
menuElement.triggerHandler('click');
|
||||
|
||||
expect(scope._expandedMenu.menu).to.eql(null)
|
||||
});
|
||||
}));
|
||||
|
||||
it('closes a connected menu when child element is clicked', inject(function($compile) {
|
||||
var menuElementWithChild = $compile('<li></li>')(scope);
|
||||
var menuElementChild = $compile('<a data-close-menu></a>')(scope);
|
||||
scope._expandedMenu = { menu: 'mobile' };
|
||||
|
||||
it('closes a connected menu when child element is clicked', function() {
|
||||
scope._expandedMenu = {};
|
||||
scope._expandedMenu.menu = 'mobile';
|
||||
menuElementWithChild.appendTo(document.body);
|
||||
menuElementChild.appendTo(menuElementWithChild);
|
||||
|
||||
menuElementChild.triggerHandler('click');
|
||||
|
||||
expect(scope._expandedMenu.menu).to.eql(null)
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user