summaryrefslogtreecommitdiff
path: root/spec/javascripts/notes/stores/getters_spec.js
blob: 48ee1bf9a521bb70c9e9976c459c0f4cad8907f4 (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
import * as getters from '~/notes/stores/getters';
import { notesDataMock, userDataMock, issueDataMock, individualNote } from '../mock_data';

describe('Getters Notes Store', () => {
  let state;
  beforeEach(() => {
    state = {
      notes: [individualNote],
      targetNoteHash: 'hash',
      lastFetchedAt: 'timestamp',

      notesData: notesDataMock,
      userData: userDataMock,
      issueData: issueDataMock,
    };
  });
  describe('notes', () => {
    it('should return all notes in the store', () => {
      expect(getters.notes(state)).toEqual([individualNote]);
    });
  });

  describe('targetNoteHash', () => {
    it('should return `targetNoteHash`', () => {
      expect(getters.targetNoteHash(state)).toEqual('hash');
    });
  });

  describe('getNotesData', () => {
    it('should return all data in `notesData`', () => {
      expect(getters.getNotesData(state)).toEqual(notesDataMock);
    });
  });

  describe('getIssueData', () => {
    it('should return all data in `issueData`', () => {
      expect(getters.getIssueData(state)).toEqual(issueDataMock);
    });
  });

  describe('getUserData', () => {
    it('should return all data in `userData`', () => {
      expect(getters.getUserData(state)).toEqual(userDataMock);
    });
  });

  describe('notesById', () => {
    it('should return the note for the given id', () => {
      expect(getters.notesById(state)).toEqual({ 1390: individualNote.notes[0] });
    });
  });

  describe('getCurrentUserLastNote', () => {
    it('should return the last note of the current user', () => {
      expect(getters.getCurrentUserLastNote(state)).toEqual(individualNote.notes[0]);
    });
  });
});