Merge branch 'develop' into sabrecat/party-page
Conflicts: common/dist/sprites/habitrpg-shared.css common/dist/sprites/spritesmith0.png common/dist/sprites/spritesmith2.png common/dist/sprites/spritesmith3.css common/dist/sprites/spritesmith3.png common/dist/sprites/spritesmith4.css common/dist/sprites/spritesmith4.png
This commit is contained in:
@@ -1,25 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
describe('closeMenu Directive', function() {
|
||||
var menuElement, 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">';
|
||||
|
||||
menuElement = $compile(element)(scope);
|
||||
scope.$digest();
|
||||
}));
|
||||
|
||||
it('closes a connected menu when element is clicked', function() {
|
||||
scope._expandedMenu = '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).to.eql(null)
|
||||
});
|
||||
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' };
|
||||
|
||||
menuElementWithChild.appendTo(document.body);
|
||||
menuElementChild.appendTo(menuElementWithChild);
|
||||
menuElementChild.triggerHandler('click');
|
||||
|
||||
expect(scope._expandedMenu.menu).to.eql(null)
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -20,15 +20,16 @@ describe('expandMenu Directive', function() {
|
||||
|
||||
menuElement.triggerHandler('click');
|
||||
|
||||
expect(scope._expandedMenu).to.eql('mobile')
|
||||
expect(scope._expandedMenu.menu).to.eql('mobile')
|
||||
});
|
||||
|
||||
it('closes a connected menu when it is already open', function() {
|
||||
scope._expandedMenu = 'mobile';
|
||||
scope._expandedMenu = {};
|
||||
scope._expandedMenu.menu = 'mobile';
|
||||
menuElement.appendTo(document.body);
|
||||
|
||||
menuElement.triggerHandler('click');
|
||||
|
||||
expect(scope._expandedMenu).to.eql(null)
|
||||
expect(scope._expandedMenu.menu).to.eql(null)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
describe('focusElement Directive', function() {
|
||||
var elementToFocus, scope;
|
||||
|
||||
beforeEach(module('habitrpg'));
|
||||
|
||||
beforeEach(inject(function($rootScope, $compile) {
|
||||
scope = $rootScope.$new();
|
||||
|
||||
scope.focusThisLink = false;
|
||||
var element = '<input data-focus-element="focusThisLink" />';
|
||||
|
||||
elementToFocus = $compile(element)(scope);
|
||||
scope.$digest();
|
||||
}));
|
||||
|
||||
it('places focus on the element it is applied to when the expression it binds to evaluates to true', inject(function($timeout) {
|
||||
var focusSpy = sandbox.spy();
|
||||
|
||||
elementToFocus.appendTo(document.body);
|
||||
elementToFocus.on('focus', focusSpy);
|
||||
scope.focusThisLink = true;
|
||||
scope.$digest();
|
||||
|
||||
$timeout.flush();
|
||||
expect(document.activeElement.dataset.focusElement).to.eql("focusThisLink");
|
||||
expect(focusSpy).to.have.been.called;
|
||||
}));
|
||||
});
|
||||
@@ -1,28 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
describe('focusMe Directive', function() {
|
||||
var element, scope;
|
||||
|
||||
beforeEach(module('habitrpg'));
|
||||
|
||||
beforeEach(inject(function($rootScope, $compile) {
|
||||
scope = $rootScope.$new();
|
||||
|
||||
element = "<input focus-me></input>";
|
||||
|
||||
element = $compile(element)(scope);
|
||||
scope.$digest();
|
||||
}));
|
||||
|
||||
it('focuses the element when appended to the DOM', function() {
|
||||
inject(function($timeout) {
|
||||
var focusSpy = sandbox.spy();
|
||||
|
||||
element.appendTo(document.body);
|
||||
element.on('focus', focusSpy);
|
||||
|
||||
$timeout.flush();
|
||||
expect(focusSpy).to.have.been.called;
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user