Created
September 26, 2015 18:24
-
-
Save toddbranch/a3fa520ce3cd7059d20b to your computer and use it in GitHub Desktop.
Angular focusOnClick Directive Tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('focusOnClick', function() { | |
| var button; | |
| var $testInput; | |
| beforeEach(function() { | |
| module('gmail'); | |
| inject(function($compile, $rootScope) { | |
| button = $compile('<button focus-on-click="#test-input"></button>')($rootScope.$new()); | |
| $testInput = $('<input id="test-input" type="text">'); | |
| $('body').append($testInput); | |
| }); | |
| }); | |
| afterEach(function() { | |
| $testInput.remove(); | |
| button.remove(); | |
| }); | |
| // NOTE: $testInput.is(:focus) is not supported by Phantom | |
| it('focuses the desired element on click', function() { | |
| expect(document.activeElement).not.toBe($testInput[0]); | |
| button.trigger('click'); | |
| expect(document.activeElement).toBe($testInput[0]); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment