client/src/actions/__tests__/notesActions.test.js
author Alexandre Segura <mex.zktk@gmail.com>
Thu, 01 Jun 2017 11:39:20 +0200
changeset 13 d6eef0e9f7e1
parent 3 3b5d37d84cfe
child 168 ea92f4fe783d
permissions -rw-r--r--
Fix test.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
// cf. http://redux.js.org/docs/recipes/WritingTests.html
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
import * as actions from '../notesActions'
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
import * as types from '../../constants/actionTypes'
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
describe('actions', () => {
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
  it('should create an action to add a note', () => {
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
    const text = 'test note'
13
d6eef0e9f7e1 Fix test.
Alexandre Segura <mex.zktk@gmail.com>
parents: 3
diff changeset
    10
    const session = { id: 'abcd123' }
3
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
    const expectedAction = {
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
      type: types.ADD_NOTE,
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
      note: {
13
d6eef0e9f7e1 Fix test.
Alexandre Segura <mex.zktk@gmail.com>
parents: 3
diff changeset
    14
        id: expect.stringMatching(/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/),
d6eef0e9f7e1 Fix test.
Alexandre Segura <mex.zktk@gmail.com>
parents: 3
diff changeset
    15
        session: session.id,
d6eef0e9f7e1 Fix test.
Alexandre Segura <mex.zktk@gmail.com>
parents: 3
diff changeset
    16
        text: text
3
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
      }
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    }
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
13
d6eef0e9f7e1 Fix test.
Alexandre Segura <mex.zktk@gmail.com>
parents: 3
diff changeset
    20
    const receivedAction = actions.addNote(session, text);
3
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
    expect(receivedAction).toMatchObject(expectedAction);
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
3b5d37d84cfe Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
  })
13
d6eef0e9f7e1 Fix test.
Alexandre Segura <mex.zktk@gmail.com>
parents: 3
diff changeset
    24
})