kaoDev/react-ts-sample

View on GitHub
src/__tests__/actions/actionCreators.test.ts

Summary

Maintainability
A
3 hrs
Test Coverage
import { textChanged, inputChanged } from 'actions/actionCreators'
import { ActionType } from 'actions/actionTypes'

const textValue = 'text'

describe('textChanged should create a valid action', () => {
  const action = textChanged(textValue)

  test('action should equal expected model', () => {
    expect(action).toEqual({
      type: ActionType.TEXT_CHANGED,
      text: textValue,
    })
  })
})

describe('inputChanged should create a valid action', () => {
  const action = inputChanged(textValue)

  test('action should equal expected model', () => {
    expect(action).toEqual({
      type: ActionType.INPUT_CHANGED,
      input: textValue,
    })
  })
})