Welcome to mirror list, hosted at ThFree Co, Russian Federation.

nuget_installation_spec.js « components « details « packages « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 685d0808dd92ca4811573dc6a0e34736014c4e9d (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import Vuex from 'vuex';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { nugetPackage as packageEntity } from 'jest/packages/mock_data';
import { registryUrl as nugetPath } from 'jest/packages/details/mock_data';
import NugetInstallation from '~/packages/details/components/nuget_installation.vue';
import CodeInstructions from '~/vue_shared/components/registry/code_instruction.vue';
import { TrackingActions } from '~/packages/details/constants';

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

describe('NugetInstallation', () => {
  let wrapper;

  const nugetInstallationCommandStr = 'foo/command';
  const nugetSetupCommandStr = 'foo/setup';

  const store = new Vuex.Store({
    state: {
      packageEntity,
      nugetPath,
    },
    getters: {
      nugetInstallationCommand: () => nugetInstallationCommandStr,
      nugetSetupCommand: () => nugetSetupCommandStr,
    },
  });

  const findCodeInstructions = () => wrapper.findAll(CodeInstructions);

  function createComponent() {
    wrapper = shallowMount(NugetInstallation, {
      localVue,
      store,
    });
  }

  beforeEach(() => {
    createComponent();
  });

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

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

  describe('installation commands', () => {
    it('renders the correct command', () => {
      expect(findCodeInstructions().at(0).props()).toMatchObject({
        instruction: nugetInstallationCommandStr,
        trackingAction: TrackingActions.COPY_NUGET_INSTALL_COMMAND,
      });
    });
  });

  describe('setup commands', () => {
    it('renders the correct command', () => {
      expect(findCodeInstructions().at(1).props()).toMatchObject({
        instruction: nugetSetupCommandStr,
        trackingAction: TrackingActions.COPY_NUGET_SETUP_COMMAND,
      });
    });
  });
});