Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: react-floki

on:
push:
branches:
- master

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- name: bump version
run: |
git config --global user.email "git@wednesday.is"
git config --global user.name "Git"
npm version patch -m 'Bump up'
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Publish
run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
5 changes: 2 additions & 3 deletions generators/container/reducer.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
*
*/
import produce from 'immer'
import { fromJS } from 'immutable'
import { createActions } from 'reduxsauce'

export const initialState = fromJS({})
export const initialState = {}

export const { Types: {{ camelCase name }}Types, Creators: {{ camelCase name }}Creators } = createActions({
defaultAction: ['somePayload']
Expand All @@ -18,7 +17,7 @@ export const {{ camelCase name }}Reducer = (state = initialState, action) =>
produce(state, (/* draft */) => {
switch (action.type) {
case {{ camelCase name}}Types.DEFAULT_ACTION:
return state.set('somePayload', action.somePayload)
return {...state, somePayload: action.somePayload}
default:
return state
}
Expand Down
3 changes: 1 addition & 2 deletions generators/container/reducer.test.js.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// import produce from 'immer'
import { fromJS } from 'immutable';
import { {{ camelCase name }}Reducer, {{ camelCase name }}Types, initialState } from '../reducer'

/* eslint-disable default-case, no-param-reassign */
Expand All @@ -14,7 +13,7 @@ describe('{{ properCase name }} reducer tests', () => {
})

it('should return the update the state when an action of type DEFAULT is dispatched', () => {
const expectedResult = fromJS(state.toJS()).set('somePayload', 'Mohammed Ali Chherawalla')
const expectedResult = {...state, somePayload: 'Mohammed Ali Chherawalla'}
expect(
{{ camelCase name }}Reducer(state, {
type: {{ camelCase name}}Types.DEFAULT_ACTION,
Expand Down
2 changes: 1 addition & 1 deletion generators/container/selectors.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { initialState } from './reducer'
* Direct selector to the {{ camelCase name }} state domain
*/

const select{{ properCase name }}Domain = state => (state.{{ camelCase name }} || initialState).toJS()
const select{{ properCase name }}Domain = state => state.{{ camelCase name }} || initialState

const makeSelect{{ properCase name }} = () =>
createSelector(select{{ properCase name }}Domain, substate => substate)
Expand Down
5 changes: 2 additions & 3 deletions generators/container/selectors.test.js.hbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { fromJS } from 'immutable'
import { select{{ properCase name }}Domain } from '../selectors'

describe('{{ properCase name }} selector tests', () => {
let mockedState

beforeEach(() => {
mockedState = {
{{ camelCase name }}: fromJS({})
{{ camelCase name }}: {}
}
})

it('should select the user state', () => {
expect(select{{ properCase name }}Domain(mockedState)).toEqual(mockedState.{{ camelCase name }}.toJS())
expect(select{{ properCase name }}Domain(mockedState)).toEqual(mockedState.{{ camelCase name }})
})
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-floki",
"version": "1.0.83",
"version": "1.0.84",
"description": "A React component, container and test generation library",
"repository": {
"type": "git",
Expand Down