debian-mirror-gitlab/spec/javascripts/version_check_image_spec.js

36 lines
1 KiB
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2017-09-10 17:25:29 +05:30
import VersionCheckImage from '~/version_check_image';
import ClassSpecHelper from './helpers/class_spec_helper';
2017-08-17 22:00:37 +05:30
2018-12-13 13:39:08 +05:30
describe('VersionCheckImage', function() {
describe('bindErrorEvent', function() {
2017-08-17 22:00:37 +05:30
ClassSpecHelper.itShouldBeAStaticMethod(VersionCheckImage, 'bindErrorEvent');
2018-12-13 13:39:08 +05:30
beforeEach(function() {
2017-08-17 22:00:37 +05:30
this.imageElement = $('<div></div>');
});
2018-12-13 13:39:08 +05:30
it('registers an error event', function() {
2017-08-17 22:00:37 +05:30
spyOn($.prototype, 'on');
2018-12-13 13:39:08 +05:30
spyOn($.prototype, 'off').and.callFake(function() {
return this;
});
2017-08-17 22:00:37 +05:30
VersionCheckImage.bindErrorEvent(this.imageElement);
expect($.prototype.off).toHaveBeenCalledWith('error');
expect($.prototype.on).toHaveBeenCalledWith('error', jasmine.any(Function));
});
2018-12-13 13:39:08 +05:30
it('hides the imageElement on error', function() {
2017-08-17 22:00:37 +05:30
spyOn($.prototype, 'hide');
VersionCheckImage.bindErrorEvent(this.imageElement);
this.imageElement.trigger('error');
expect($.prototype.hide).toHaveBeenCalled();
});
});
});