diff --git a/test/spec/directives/task-focus.directives.js b/test/spec/directives/task-focus.directives.js index 9b4c214530..691e03bb4d 100644 --- a/test/spec/directives/task-focus.directives.js +++ b/test/spec/directives/task-focus.directives.js @@ -9,17 +9,25 @@ describe('taskFocus Directive', function() { scope = $rootScope.$new(); scope.focusThisLink = false; - var element = ''; + 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() { + 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(); - expect(document.activeElement).to.eql(elementToFocus) - }); + + $timeout.flush(); + expect(document.activeElement.dataset.taskFocus).to.eql("focusThisLink"); + expect(focusSpy).to.have.been.called; + }) + ); });