Skip to content

Instantly share code, notes, and snippets.

@toddbranch
Created September 26, 2015 18:24
Show Gist options
  • Select an option

  • Save toddbranch/a3fa520ce3cd7059d20b to your computer and use it in GitHub Desktop.

Select an option

Save toddbranch/a3fa520ce3cd7059d20b to your computer and use it in GitHub Desktop.
Angular focusOnClick Directive Tests
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