mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
reorganize old client tests
This commit is contained in:
30
test/client-old/spec/directives/focus-element.directive.js
Normal file
30
test/client-old/spec/directives/focus-element.directive.js
Normal file
@@ -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;
|
||||
}));
|
||||
});
|
||||
Reference in New Issue
Block a user