Fixed broken test by change element to a focusable element
This commit is contained in:
@@ -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;
|
||||
})
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user