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

mutations_spec.js « new « store « feature_flags « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c97e62247bb62a8e74600e018add35a698de2535 (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
import * as types from '~/feature_flags/store/new/mutation_types';
import mutations from '~/feature_flags/store/new/mutations';
import state from '~/feature_flags/store/new/state';

describe('Feature flags New Module Mutations', () => {
  let stateCopy;

  beforeEach(() => {
    stateCopy = state({ endpoint: 'feature_flags.json', path: 'feature_flags' });
  });

  describe('REQUEST_CREATE_FEATURE_FLAG', () => {
    it('should set isSendingRequest to true', () => {
      mutations[types.REQUEST_CREATE_FEATURE_FLAG](stateCopy);

      expect(stateCopy.isSendingRequest).toEqual(true);
    });

    it('should set error to an empty array', () => {
      mutations[types.REQUEST_CREATE_FEATURE_FLAG](stateCopy);

      expect(stateCopy.error).toEqual([]);
    });
  });

  describe('RECEIVE_CREATE_FEATURE_FLAG_SUCCESS', () => {
    it('should set isSendingRequest to false', () => {
      mutations[types.RECEIVE_CREATE_FEATURE_FLAG_SUCCESS](stateCopy);

      expect(stateCopy.isSendingRequest).toEqual(false);
    });
  });

  describe('RECEIVE_CREATE_FEATURE_FLAG_ERROR', () => {
    beforeEach(() => {
      mutations[types.RECEIVE_CREATE_FEATURE_FLAG_ERROR](stateCopy, {
        message: ['Name is required'],
      });
    });

    it('should set isSendingRequest to false', () => {
      expect(stateCopy.isSendingRequest).toEqual(false);
    });

    it('should set hasError to true', () => {
      expect(stateCopy.error).toEqual(['Name is required']);
    });
  });
});