2018-03-09 15:18:59 -05:00
|
|
|
import $ from 'jquery';
|
2017-05-16 17:01:51 -04:00
|
|
|
import VersionCheckImage from '~/version_check_image';
|
|
|
|
import ClassSpecHelper from './helpers/class_spec_helper';
|
2017-01-12 09:00:06 -05:00
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
describe('VersionCheckImage', function() {
|
|
|
|
describe('bindErrorEvent', function() {
|
2017-01-12 09:00:06 -05:00
|
|
|
ClassSpecHelper.itShouldBeAStaticMethod(VersionCheckImage, 'bindErrorEvent');
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
beforeEach(function() {
|
2017-01-12 09:00:06 -05:00
|
|
|
this.imageElement = $('<div></div>');
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('registers an error event', function() {
|
2017-01-12 09:00:06 -05:00
|
|
|
spyOn($.prototype, 'on');
|
2018-10-17 03:13:26 -04:00
|
|
|
spyOn($.prototype, 'off').and.callFake(function() {
|
|
|
|
return this;
|
|
|
|
});
|
2017-01-12 09:00:06 -05:00
|
|
|
|
|
|
|
VersionCheckImage.bindErrorEvent(this.imageElement);
|
|
|
|
|
|
|
|
expect($.prototype.off).toHaveBeenCalledWith('error');
|
|
|
|
expect($.prototype.on).toHaveBeenCalledWith('error', jasmine.any(Function));
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('hides the imageElement on error', function() {
|
2017-01-12 09:00:06 -05:00
|
|
|
spyOn($.prototype, 'hide');
|
|
|
|
|
|
|
|
VersionCheckImage.bindErrorEvent(this.imageElement);
|
|
|
|
|
|
|
|
this.imageElement.trigger('error');
|
|
|
|
|
|
|
|
expect($.prototype.hide).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|