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

mutations_spec.js « stores « gke_cluster « create_cluster « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2a742b6ed8f46d452ba7da95cad63a335afc91fb (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 createState from '~/create_cluster/gke_cluster/store/state';
import * as types from '~/create_cluster/gke_cluster/store/mutation_types';
import mutations from '~/create_cluster/gke_cluster/store/mutations';
import {
  gapiProjectsResponseMock,
  gapiZonesResponseMock,
  gapiMachineTypesResponseMock,
} from '../mock_data';

describe('GCP Cluster Dropdown Store Mutations', () => {
  describe.each`
    mutation                                   | stateProperty                   | mockData
    ${types.SET_PROJECTS}                      | ${'projects'}                   | ${gapiProjectsResponseMock.projects}
    ${types.SET_ZONES}                         | ${'zones'}                      | ${gapiZonesResponseMock.items}
    ${types.SET_MACHINE_TYPES}                 | ${'machineTypes'}               | ${gapiMachineTypesResponseMock.items}
    ${types.SET_MACHINE_TYPE}                  | ${'selectedMachineType'}        | ${gapiMachineTypesResponseMock.items[0].name}
    ${types.SET_ZONE}                          | ${'selectedZone'}               | ${gapiZonesResponseMock.items[0].name}
    ${types.SET_PROJECT}                       | ${'selectedProject'}            | ${gapiProjectsResponseMock.projects[0]}
    ${types.SET_PROJECT_BILLING_STATUS}        | ${'projectHasBillingEnabled'}   | ${true}
    ${types.SET_IS_VALIDATING_PROJECT_BILLING} | ${'isValidatingProjectBilling'} | ${true}
  `('$mutation', ({ mutation, stateProperty, mockData }) => {
    it(`should set the mutation payload to the ${stateProperty} state property`, () => {
      const state = createState();

      expect(state[stateProperty]).not.toBe(mockData);

      mutations[mutation](state, mockData);

      expect(state[stateProperty]).toBe(mockData);
    });
  });
});