summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_shared/components/expand_button_spec.js
blob: 98fee9a74a5ded676c62fae0eb1f46ed520f7a8e (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
import Vue from 'vue';
import expandButton from '~/vue_shared/components/expand_button.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';

describe('expand button', () => {
  const Component = Vue.extend(expandButton);
  let vm;

  beforeEach(() => {
    vm = mountComponent(Component, {
      slots: {
        expanded: '<p>Expanded!</p>',
      },
    });
  });

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

  it('renders a collpased button', () => {
    expect(vm.$children[0].iconTestClass).toEqual('ic-ellipsis_h');
  });

  it('hides expander on click', done => {
    vm.$el.querySelector('button').click();
    vm.$nextTick(() => {
      expect(vm.$el.querySelector('button').getAttribute('style')).toEqual('display: none;');
      done();
    });
  });
});