summaryrefslogtreecommitdiff
path: root/spec/frontend/registry/settings/components/registry_settings_app_spec.js
blob: 666d970aa6bbdc33a982d1399874c1b8cc0c3dfb (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
40
import Vuex from 'vuex';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import component from '~/registry/settings/components/registry_settings_app.vue';
import { createStore } from '~/registry/settings/stores/';

const localVue = createLocalVue();
localVue.use(Vuex);

describe('Registry List', () => {
  let wrapper;
  let store;

  const helpPagePath = 'foo';
  const findHelpLink = () => wrapper.find({ ref: 'help-link' }).find('a');

  const mountComponent = (options = {}) =>
    shallowMount(component, {
      sync: false,
      store,
      ...options,
    });

  beforeEach(() => {
    store = createStore();
    store.dispatch('setInitialState', { helpPagePath });
    wrapper = mountComponent();
  });

  afterEach(() => {
    wrapper.destroy();
  });

  it('renders', () => {
    expect(wrapper.element).toMatchSnapshot();
  });

  it('renders an help link dependant on the helphPagePath', () => {
    expect(findHelpLink().attributes('href')).toBe(helpPagePath);
  });
});