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

mutations_spec.js « store « static_site_editor « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: db3a1081af5f26cd18df626ebb272adc71f84698 (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
import createState from '~/static_site_editor/store/state';
import mutations from '~/static_site_editor/store/mutations';
import * as types from '~/static_site_editor/store/mutation_types';
import { sourceContentTitle as title, sourceContent as content } from '../mock_data';

describe('Static Site Editor Store mutations', () => {
  let state;

  beforeEach(() => {
    state = createState();
  });

  describe('loadContent', () => {
    beforeEach(() => {
      mutations[types.LOAD_CONTENT](state);
    });

    it('sets isLoadingContent to true', () => {
      expect(state.isLoadingContent).toBe(true);
    });
  });

  describe('receiveContentSuccess', () => {
    const payload = { title, content };

    beforeEach(() => {
      mutations[types.RECEIVE_CONTENT_SUCCESS](state, payload);
    });

    it('sets current state to LOADING', () => {
      expect(state.isLoadingContent).toBe(false);
    });

    it('sets title', () => {
      expect(state.title).toBe(payload.title);
    });

    it('sets originalContent and content', () => {
      expect(state.content).toBe(payload.content);
      expect(state.originalContent).toBe(payload.content);
    });
  });

  describe('receiveContentError', () => {
    beforeEach(() => {
      mutations[types.RECEIVE_CONTENT_ERROR](state);
    });

    it('sets current state to LOADING_ERROR', () => {
      expect(state.isLoadingContent).toBe(false);
    });
  });

  describe('setContent', () => {
    it('sets content', () => {
      mutations[types.SET_CONTENT](state, content);

      expect(state.content).toBe(content);
    });
  });
});