summaryrefslogtreecommitdiff
path: root/spec/frontend/packages_and_registries/infrastructure_registry/components/details/store/mutations_spec.js
blob: 6efefea4a142e8a01b3a85c97b594910d94723b0 (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 * as types from '~/packages_and_registries/infrastructure_registry/details/store/mutation_types';
import mutations from '~/packages_and_registries/infrastructure_registry/details/store/mutations';
import { npmPackage as packageEntity } from 'jest/packages/mock_data';

describe('Mutations package details Store', () => {
  let mockState;

  beforeEach(() => {
    mockState = {
      packageEntity,
    };
  });

  describe('SET_LOADING', () => {
    it('should set loading', () => {
      mutations[types.SET_LOADING](mockState, true);

      expect(mockState.isLoading).toEqual(true);
    });
  });

  describe('SET_PACKAGE_VERSIONS', () => {
    it('should set the package entity versions', () => {
      const fakeVersions = [1, 2, 3];

      mutations[types.SET_PACKAGE_VERSIONS](mockState, fakeVersions);

      expect(mockState.packageEntity.versions).toEqual(fakeVersions);
    });
  });
  describe('UPDATE_PACKAGE_FILES', () => {
    it('should update the packageFiles', () => {
      const files = [1, 2, 3];

      mutations[types.UPDATE_PACKAGE_FILES](mockState, files);

      expect(mockState.packageFiles).toEqual(files);
    });
  });
});