actions_spec.js 2.0 KB
Newer Older
F
Filipa Lacerda 已提交
1
import * as actions from '~/notes/stores/actions';
2
import testAction from '../../helpers/vuex_action_helper';
S
Simon Knox 已提交
3
import { discussionMock, notesDataMock, userDataMock, noteableDataMock, individualNote } from '../mock_data';
4

F
Filipa Lacerda 已提交
5
describe('Actions Notes Store', () => {
F
Filipa Lacerda 已提交
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);
F
Filipa Lacerda 已提交
11 12 13
    });
  });

S
Simon Knox 已提交
14
  describe('setNoteableData', () => {
15
    it('should set received issue data', (done) => {
S
Simon Knox 已提交
16 17
      testAction(actions.setNoteableData, null, { noteableData: {} }, [
        { type: 'SET_NOTEABLE_DATA', payload: noteableDataMock },
18 19
      ], done);
    });
F
Filipa Lacerda 已提交
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);
    });
F
Filipa Lacerda 已提交
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);
    });
F
Filipa Lacerda 已提交
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);
F
Filipa Lacerda 已提交
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);
    });
F
Filipa Lacerda 已提交
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);
F
Filipa Lacerda 已提交
59 60 61
    });
  });
});