diff --git a/test/spec/directives/task-focus.directives.js b/test/spec/directives/task-focus.directives.js new file mode 100644 index 0000000000..9b4c214530 --- /dev/null +++ b/test/spec/directives/task-focus.directives.js @@ -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 = ''; + + 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) + }); + +});