client/src/actions/__tests__/notesActions.test.js
changeset 168 ea92f4fe783d
parent 13 d6eef0e9f7e1
equal deleted inserted replaced
167:1f340f3597a8 168:ea92f4fe783d
     4 import * as types from '../../constants/actionTypes'
     4 import * as types from '../../constants/actionTypes'
     5 
     5 
     6 describe('actions', () => {
     6 describe('actions', () => {
     7 
     7 
     8   it('should create an action to add a note', () => {
     8   it('should create an action to add a note', () => {
     9     const text = 'test note'
     9     const text = 'hello world';
    10     const session = { id: 'abcd123' }
    10     const dateNote = Date.now();
       
    11     const data = {
       
    12       raw: {
       
    13         document: {
       
    14           nodes: [
       
    15             {
       
    16               object: 'block',
       
    17               type: 'paragraph',
       
    18               nodes: [
       
    19                 {
       
    20                   object: 'text',
       
    21                   leaves: [
       
    22                     {
       
    23                       text: text,
       
    24                     },
       
    25                   ],
       
    26                 },
       
    27               ],
       
    28             },
       
    29           ],
       
    30         },
       
    31       },
       
    32       plain: text,
       
    33       html: text,
       
    34       startedAt: dateNote,
       
    35       finishedAt: dateNote + 10000,
       
    36       categories: [],
       
    37       marginComment: 'empty',
       
    38     }
       
    39     const session = { _id: 'abcd123' }
    11     const expectedAction = {
    40     const expectedAction = {
    12       type: types.ADD_NOTE,
    41       type: types.ADD_NOTE,
    13       note: {
    42       note: {
    14         id: expect.stringMatching(/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/),
    43         _id: expect.stringMatching(/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/),
    15         session: session.id,
    44         session: session._id
    16         text: text
       
    17       }
    45       }
    18     }
    46     }
    19 
    47 
    20     const receivedAction = actions.addNote(session, text);
    48     const receivedAction = actions.addNote(session, data);
    21     expect(receivedAction).toMatchObject(expectedAction);
    49     expect(receivedAction).toMatchObject(expectedAction);
    22 
    50 
    23   })
    51   })
    24 })
    52 })