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

35 lines
938 B
JavaScript
Raw Normal View History

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