summaryrefslogtreecommitdiff
path: root/spec/javascripts/ide/components/commit_sidebar/unstage_button_spec.js
blob: 917bbb9fb46a111859a8f7d4f2d114d29629a1b1 (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
35
36
37
38
39
import Vue from 'vue';
import store from '~/ide/stores';
import unstageButton from '~/ide/components/commit_sidebar/unstage_button.vue';
import { createComponentWithStore } from '../../../helpers/vue_mount_component_helper';
import { file, resetStore } from '../../helpers';

describe('IDE unstage file button', () => {
  let vm;
  let f;

  beforeEach(() => {
    const Component = Vue.extend(unstageButton);
    f = file();

    vm = createComponentWithStore(Component, store, {
      path: f.path,
    });

    spyOn(vm, 'unstageChange');

    vm.$mount();
  });

  afterEach(() => {
    vm.$destroy();

    resetStore(vm.$store);
  });

  it('renders button to unstage', () => {
    expect(vm.$el.querySelectorAll('.btn').length).toBe(1);
  });

  it('calls store with unnstage button', () => {
    vm.$el.querySelector('.btn').click();

    expect(vm.unstageChange).toHaveBeenCalledWith(f.path);
  });
});