BigW Consortium Gitlab

actions_spec.js 1.98 KB
Newer Older
1
import * as actions from '~/notes/stores/actions';
2
import testAction from '../../helpers/vuex_action_helper';
3
import { discussionMock, notesDataMock, userDataMock, issueDataMock, individualNote } from '../mock_data';
4

5
describe('Actions Notes Store', () => {
6
  describe('setNotesData', () => {
7 8 9 10
    it('should set received notes data', (done) => {
      testAction(actions.setNotesData, null, { notesData: {} }, [
        { type: 'SET_NOTES_DATA', payload: notesDataMock },
      ], done);
11 12 13 14
    });
  });

  describe('setIssueData', () => {
15 16 17 18 19
    it('should set received issue data', (done) => {
      testAction(actions.setIssueData, null, { issueData: {} }, [
        { type: 'SET_ISSUE_DATA', payload: issueDataMock },
      ], done);
    });
20 21 22
  });

  describe('setUserData', () => {
23 24 25 26 27
    it('should set received user data', (done) => {
      testAction(actions.setUserData, null, { userData: {} }, [
        { type: 'SET_USER_DATA', payload: userDataMock },
      ], done);
    });
28 29 30
  });

  describe('setLastFetchedAt', () => {
31 32 33 34 35
    it('should set received timestamp', (done) => {
      testAction(actions.setLastFetchedAt, null, { lastFetchedAt: {} }, [
        { type: 'SET_LAST_FETCHED_AT', payload: 'timestamp' },
      ], done);
    });
36 37 38
  });

  describe('setInitialNotes', () => {
39 40
    it('should set initial notes', (done) => {
      testAction(actions.setInitialNotes, null, { notes: [] }, [
41
        { type: 'SET_INITIAL_NOTES', payload: [individualNote] },
42
      ], done);
43 44 45 46
    });
  });

  describe('setTargetNoteHash', () => {
47 48 49 50 51
    it('should set target note hash', (done) => {
      testAction(actions.setTargetNoteHash, null, { notes: [] }, [
        { type: 'SET_TARGET_NOTE_HASH', payload: 'hash' },
      ], done);
    });
52 53 54
  });

  describe('toggleDiscussion', () => {
55 56 57 58
    it('should toggle discussion', (done) => {
      testAction(actions.toggleDiscussion, null, { notes: [discussionMock] }, [
        { type: 'TOGGLE_DISCUSSION', payload: { discussionId: discussionMock.id } },
      ], done);
59 60 61
    });
  });
});