summaryrefslogtreecommitdiff
path: root/spec/frontend/static_site_editor/store/getters_spec.js
blob: 1b482db93668a9892532a927122845ea6d82dce3 (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
import createState from '~/static_site_editor/store/state';
import { isContentLoaded, contentChanged } from '~/static_site_editor/store/getters';
import { sourceContent as content } from '../mock_data';

describe('Static Site Editor Store getters', () => {
  describe('isContentLoaded', () => {
    it('returns true when originalContent is not empty', () => {
      expect(isContentLoaded(createState({ originalContent: content }))).toBe(true);
    });

    it('returns false when originalContent is empty', () => {
      expect(isContentLoaded(createState({ originalContent: '' }))).toBe(false);
    });
  });

  describe('contentChanged', () => {
    it('returns true when content and originalContent are different', () => {
      const state = createState({ content, originalContent: 'something else' });

      expect(contentChanged(state)).toBe(true);
    });

    it('returns false when content and originalContent are the same', () => {
      const state = createState({ content, originalContent: content });

      expect(contentChanged(state)).toBe(false);
    });
  });
});