From a3cd2c796a42fca5f7348b40650352e6ef75385b Mon Sep 17 00:00:00 2001 From: Lukas Prokop Date: Fri, 21 Mar 2014 23:06:24 +0100 Subject: [PATCH] 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 --- test/unit/spriteSpec.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/unit/spriteSpec.js b/test/unit/spriteSpec.js index ebb867b..7a1e690 100644 --- a/test/unit/spriteSpec.js +++ b/test/unit/spriteSpec.js @@ -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); }); });