habitica-self-host/test/spec/directives/focus-me.directive.spec.js

29 lines
611 B
JavaScript
Raw Normal View History

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();
}));
it('focuses the element when appended to the DOM', function() {
2015-06-08 12:35:10 +00:00
inject(function($timeout) {
var focusSpy = sandbox.spy();
2015-06-08 12:35:10 +00:00
element.appendTo(document.body);
element.on('focus', focusSpy);
2015-06-08 12:35:10 +00:00
$timeout.flush();
expect(focusSpy).to.have.been.called;
2015-06-08 12:35:10 +00:00
});
});
});