Added test for task-focus directive

This commit is contained in:
TheHollidayInn 2015-08-25 16:11:18 -05:00
parent 6564cb52dc
commit 06f59bed7c

View file

@ -0,0 +1,25 @@
'use strict';
describe('taskFocus Directive', function() {
var elementToFocus, scope;
beforeEach(module('habitrpg'));
beforeEach(inject(function($rootScope, $compile) {
scope = $rootScope.$new();
scope.focusThisLink = false;
var element = '<a data-task-focus="focusThisLink" ></a>';
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', function() {
elementToFocus.appendTo(document.body);
scope.focusThisLink = true;
scope.$digest();
expect(document.activeElement).to.eql(elementToFocus)
});
});