gitlab-org--gitlab-foss/spec/javascripts/issuable_context_spec.js

35 lines
938 B
JavaScript
Raw Normal View History

2017-09-25 10:48:16 +00:00
/* global IssuableContext */
2017-09-22 08:11:40 +00:00
import '~/issuable_context';
import $ from 'jquery';
2017-09-22 08:11:40 +00:00
2017-09-25 10:48:16 +00:00
describe('IssuableContext', () => {
2017-09-22 08:11:40 +00:00
describe('toggleHiddenParticipants', () => {
2017-09-25 10:48:16 +00:00
const event = jasmine.createSpyObj('event', ['preventDefault']);
2017-09-22 08:11:40 +00:00
beforeEach(() => {
spyOn($.fn, 'data').and.returnValue('data');
spyOn($.fn, 'text').and.returnValue('data');
});
2017-09-28 12:12:38 +00:00
afterEach(() => {
gl.lazyLoader = undefined;
});
2017-09-25 10:48:16 +00:00
it('calls loadCheck if lazyLoader is set', () => {
2017-09-22 08:11:40 +00:00
gl.lazyLoader = jasmine.createSpyObj('lazyLoader', ['loadCheck']);
IssuableContext.prototype.toggleHiddenParticipants(event);
expect(gl.lazyLoader.loadCheck).toHaveBeenCalled();
});
2017-09-28 12:12:38 +00:00
it('does not throw if lazyLoader is not defined', () => {
2017-09-22 08:11:40 +00:00
gl.lazyLoader = undefined;
2017-09-25 10:48:16 +00:00
const toggle = IssuableContext.prototype.toggleHiddenParticipants.bind(null, event);
2017-09-22 08:11:40 +00:00
2017-09-25 10:48:16 +00:00
expect(toggle).not.toThrow();
2017-09-22 08:11:40 +00:00
});
});
});