babel-plugin-s2s-reducer-test-case

1.0.1 • Public • Published

babel-plugin-s2s-reducer-test-case

styled with prettier

s2s plugin: create reducr test case from reducer.js

Install

$ npm install --save-dev babel-plugin-s2s-state-root

Example

reducer.js

import * as Actions from './actionTypes'
 
export const initialState = {
  count: 0,
}
 
export default function(state = initialState, action) {
  switch (action.type) {
    case Actions.INCREMENT:
      return { count: state + 1 }
    case Actions.DECREMENT:
      return { count: state - 1 }
    default:
      return state
  }
}

IN:

import reducer, { initialState } from './actions'

OUT:

import reducer, { initialState } from './actions'
 
test('handle INCREMENT', () => {
  expect(actions.increment()).toEqual({ count: 0 })
})
 
test('handle DECREMENT', () => {
  expect(actions.decrement()).toEqual({ count: 0 })
})

And, Just change {count: 0}{count: 1}.

Usage

{
  ['s2s-reducer-test-case']
}

from

type: string
required: true

reducer.js path

If you use s2s, you don't use this option.

Readme

Keywords

none

Package Sidebar

Install

npm i babel-plugin-s2s-reducer-test-case

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

9.89 kB

Total Files

6

Last publish

Collaborators

  • akameco