client/src/actions/__tests__/notesActions.test.js
author Alexandre Segura <mex.zktk@gmail.com>
Tue, 06 Jun 2017 15:56:41 +0200
changeset 19 f1b125b95fe9
parent 13 d6eef0e9f7e1
child 168 ea92f4fe783d
permissions -rw-r--r--
Introduce "annotation" plugin. - Wrap mark around text. - Store selected text in mark data. - Colorize selected text.

// cf. http://redux.js.org/docs/recipes/WritingTests.html

import * as actions from '../notesActions'
import * as types from '../../constants/actionTypes'

describe('actions', () => {

  it('should create an action to add a note', () => {
    const text = 'test note'
    const session = { id: 'abcd123' }
    const expectedAction = {
      type: types.ADD_NOTE,
      note: {
        id: expect.stringMatching(/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/),
        session: session.id,
        text: text
      }
    }

    const receivedAction = actions.addNote(session, text);
    expect(receivedAction).toMatchObject(expectedAction);

  })
})