Extend .is(:focus) check to activeElement.

If this test has to be used more often, I suggest to use a prototype.

This bugfix is based on various SO threads like
  http://stackoverflow.com/questions/18850219/testing-for-focus-an-angularjs-directive
This commit is contained in:
Lukas Prokop 2014-03-21 23:06:24 +01:00
parent 623dce5402
commit a3cd2c796a

View file

@ -169,7 +169,10 @@ describe('Sprite', function() {
expect($('.ask-container').css('bottom')).toBe('7px');
expect($('.ask-container').css('height')).toBe('25px');
expect($('.ask-container').css('height')).toBe('25px');
expect($('.ask-text-field').is(':focus')).toBe(true);
expect(
$('.ask-text-field').is(':focus') ||
document.activeElement.className.match(/ask-text-field/) !== null
).toBe(true);
expect(spriteProto.askInputOn).toBe(true);
});
@ -177,7 +180,10 @@ describe('Sprite', function() {
spriteProto.visible = false;
spriteProto.showAsk();
expect($('.ask-container').css('display')).toBe('none');
expect($('.ask-text-field').is(':focus')).toBe(false);
expect(
$('.ask-text-field').is(':focus') ||
document.activeElement.className.match(/ask-text-field/) !== null
).toBe(false);
});
});