summaryrefslogtreecommitdiff
path: root/spec/javascripts/sidebar/sidebar_service_spec.js
blob: 91a4dd669a7529c60d1a990bb032d9c4e089722d (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
import Vue from 'vue';
import SidebarService from '~/sidebar/services/sidebar_service';
import Mock from './mock_data';

describe('Sidebar service', () => {
  beforeEach(() => {
    Vue.http.interceptors.push(Mock.sidebarMockInterceptor);
    this.service = new SidebarService('/gitlab-org/gitlab-shell/issues/5.json');
  });

  afterEach(() => {
    SidebarService.singleton = null;
    Vue.http.interceptors = _.without(Vue.http.interceptors, Mock.sidebarMockInterceptor);
  });

  it('gets the data', (done) => {
    this.service.get()
      .then((resp) => {
        expect(resp).toBeDefined();
        done();
      })
      .catch(() => {});
  });

  it('updates the data', (done) => {
    this.service.update('issue[assignee_ids]', [1])
      .then((resp) => {
        expect(resp).toBeDefined();
        done();
      })
      .catch(() => {});
  });
});