mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Clean up directive tests
This commit is contained in:
@@ -1,32 +1,25 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('closeMenu Directive', function() {
|
describe('closeMenu Directive', function() {
|
||||||
var element, menuElement, scope, ctrl;
|
var menuElement, scope;
|
||||||
|
|
||||||
beforeEach(module('habitrpg'));
|
beforeEach(module('habitrpg'));
|
||||||
|
|
||||||
beforeEach(inject(function($rootScope, $compile, $controller) {
|
beforeEach(inject(function($rootScope, $compile) {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
|
|
||||||
ctrl = $controller('MenuCtrl', {$scope: scope});
|
var element = '<a data-close-menu menu="mobile">';
|
||||||
|
|
||||||
element = '<a data-close-menu menu="mobile">';
|
|
||||||
|
|
||||||
element = $compile(element)(scope);
|
|
||||||
menuElement = $compile(element)(scope);
|
menuElement = $compile(element)(scope);
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('closes a connected menu when element is clicked', function() {
|
it('closes a connected menu when element is clicked', function() {
|
||||||
inject(function($timeout) {
|
scope._expandedMenu = 'mobile';
|
||||||
var clickSpy = sandbox.spy();
|
menuElement.appendTo(document.body);
|
||||||
|
|
||||||
element.appendTo(document.body);
|
menuElement.triggerHandler('click');
|
||||||
element.on('click', clickSpy);
|
|
||||||
element.triggerHandler('click');
|
|
||||||
|
|
||||||
expect(scope._expandedMenu).to.equal(null)
|
expect(scope._expandedMenu).to.eql(null)
|
||||||
expect(clickSpy).to.have.been.called;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,32 +1,34 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('expandMenu Directive', function() {
|
describe('expandMenu Directive', function() {
|
||||||
var element, menuElement, scope, ctrl, elm;
|
var menuElement, scope;
|
||||||
|
|
||||||
beforeEach(module('habitrpg'));
|
beforeEach(module('habitrpg'));
|
||||||
|
|
||||||
beforeEach(inject(function($rootScope, $compile, $controller) {
|
beforeEach(inject(function($rootScope, $compile) {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
|
|
||||||
ctrl = $controller('MenuCtrl', {$scope: scope});
|
var element = '<a data-expand-menu menu="mobile"></a>';
|
||||||
|
|
||||||
element = '<a data-expand-menu menu="mobile"></a>';
|
|
||||||
|
|
||||||
element = $compile(element)(scope);
|
|
||||||
menuElement = $compile(element)(scope);
|
menuElement = $compile(element)(scope);
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('expands a connected menu when element is clicked', function() {
|
it('expands a connected menu when element is clicked', function() {
|
||||||
inject(function($timeout) {
|
expect(scope._expandedMenu).to.not.exist;
|
||||||
var clickSpy = sandbox.spy();
|
menuElement.appendTo(document.body);
|
||||||
|
|
||||||
element.appendTo(document.body);
|
menuElement.triggerHandler('click');
|
||||||
|
|
||||||
element.on('click', clickSpy);
|
expect(scope._expandedMenu).to.eql('mobile')
|
||||||
element.triggerHandler('click');
|
});
|
||||||
|
|
||||||
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)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user