Fixed broken test by change element to a focusable element

This commit is contained in:
TheHollidayInn 2015-08-31 16:49:34 -05:00
parent 06f59bed7c
commit 42066be2cf

View file

@ -9,17 +9,25 @@ describe('taskFocus Directive', function() {
scope = $rootScope.$new();
scope.focusThisLink = false;
var element = '<a data-task-focus="focusThisLink" ></a>';
var element = '<input data-task-focus="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', 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;
})
);
});