From 42066be2cf4a2de111e25b582b74109fded91ccb Mon Sep 17 00:00:00 2001 From: TheHollidayInn Date: Mon, 31 Aug 2015 16:49:34 -0500 Subject: [PATCH] Fixed broken test by change element to a focusable element --- test/spec/directives/task-focus.directives.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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; + }) + ); });