summaryrefslogtreecommitdiff
path: root/spec/javascripts/issuable_context_spec.js
blob: bcb2b7b24a0aa3dc130e28c81c76c6f2e1af1fa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* global IssuableContext */
import '~/issuable_context';
import $ from 'jquery';

describe('IssuableContext', () => {
  describe('toggleHiddenParticipants', () => {
    const event = jasmine.createSpyObj('event', ['preventDefault']);

    beforeEach(() => {
      spyOn($.fn, 'data').and.returnValue('data');
      spyOn($.fn, 'text').and.returnValue('data');
    });

    afterEach(() => {
      gl.lazyLoader = undefined;
    });

    it('calls loadCheck if lazyLoader is set', () => {
      gl.lazyLoader = jasmine.createSpyObj('lazyLoader', ['loadCheck']);

      IssuableContext.prototype.toggleHiddenParticipants(event);

      expect(gl.lazyLoader.loadCheck).toHaveBeenCalled();
    });

    it('does not throw if lazyLoader is not defined', () => {
      gl.lazyLoader = undefined;

      const toggle = IssuableContext.prototype.toggleHiddenParticipants.bind(null, event);

      expect(toggle).not.toThrow();
    });
  });
});