BigW Consortium Gitlab

sidebar_service_spec.js 863 Bytes
Newer Older
Clement Ho committed
1 2 3 4 5 6 7 8 9 10 11 12
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;
13
    Vue.http.interceptors = _.without(Vue.http.interceptors, Mock.sidebarMockInterceptor);
Clement Ho committed
14 15 16
  });

  it('gets the data', (done) => {
17 18 19 20 21 22
    this.service.get()
      .then((resp) => {
        expect(resp).toBeDefined();
        done();
      })
      .catch(() => {});
Clement Ho committed
23 24 25
  });

  it('updates the data', (done) => {
26 27 28 29 30 31
    this.service.update('issue[assignee_ids]', [1])
      .then((resp) => {
        expect(resp).toBeDefined();
        done();
      })
      .catch(() => {});
Clement Ho committed
32 33
  });
});