2015-06-08 12:35:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
describe('focusMe Directive', function() {
|
|
|
|
|
var element, scope;
|
|
|
|
|
|
|
|
|
|
beforeEach(module('habitrpg'));
|
|
|
|
|
|
|
|
|
|
beforeEach(inject(function($rootScope, $compile) {
|
|
|
|
|
scope = $rootScope.$new();
|
|
|
|
|
|
2015-06-08 14:01:21 +00:00
|
|
|
element = "<input focus-me></input>";
|
2015-06-08 12:35:10 +00:00
|
|
|
|
|
|
|
|
element = $compile(element)(scope);
|
|
|
|
|
scope.$digest();
|
|
|
|
|
}));
|
|
|
|
|
|
2015-06-09 03:21:55 +00:00
|
|
|
it('focuses the element when appended to the DOM', function() {
|
2015-06-08 12:35:10 +00:00
|
|
|
inject(function($timeout) {
|
2015-06-09 03:21:55 +00:00
|
|
|
var focusSpy = sinon.spy();
|
2015-06-08 12:35:10 +00:00
|
|
|
|
2015-06-09 03:21:55 +00:00
|
|
|
element.appendTo(document.body);
|
|
|
|
|
element.on('focus', focusSpy);
|
2015-06-08 12:35:10 +00:00
|
|
|
|
|
|
|
|
$timeout.flush();
|
2015-06-09 03:21:55 +00:00
|
|
|
expect(focusSpy).to.have.been.called;
|
2015-06-08 12:35:10 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|