Skip to content

Commit

Permalink
add generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
alichherawalla committed Feb 1, 2022
1 parent 7eb6a64 commit dcbc0b9
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 155 deletions.
13 changes: 7 additions & 6 deletions generated-files/container/HomeContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
*
*/

import React from 'react';
import React, { memo } from 'react';
// import PropTypes from 'prop-types'
import { connect } from 'react-redux';
import { injectIntl, FormattedMessage as T } from 'react-intl';
import { injectIntl } from 'react-intl';
import { Helmet } from 'react-helmet';

import { FormattedMessage as T } from 'react-intl';
import { createStructuredSelector } from 'reselect';
import { compose } from 'redux';
import { injectSaga } from 'redux-injectors';
import selectHomeContainerDomain from './selectors';
import { selectHomeContainer } from './selectors';
import saga from './saga';

export function HomeContainer() {
Expand All @@ -23,15 +23,15 @@ export function HomeContainer() {
<title>HomeContainer</title>
<meta name="description" content="Description of HomeContainer" />
</Helmet>
<T id="HomeContainer" />
<T id={'HomeContainer'} />
</div>
);
}

HomeContainer.propTypes = {};

const mapStateToProps = createStructuredSelector({
homeConatiner: selectHomeContainerDomain(),
homeContainer: selectHomeContainer(),
});

function mapDispatchToProps(dispatch) {
Expand All @@ -47,6 +47,7 @@ const withConnect = connect(

export default compose(
withConnect,
memo,
injectSaga({ key: 'homeContainer', saga }),
)(HomeContainer);

Expand Down
5 changes: 2 additions & 3 deletions generated-files/container/HomeContainer/reducer.js
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: homeContainerTypes,
Expand All @@ -21,7 +20,7 @@ export const homeContainerReducer = (state = initialState, action) =>
produce(state, (/* draft */) => {
switch (action.type) {
case homeContainerTypes.DEFAULT_ACTION:
return state.set('somePayload', action.somePayload);
return { ...state, somePayload: action.somePayload };
default:
return state;
}
Expand Down
9 changes: 6 additions & 3 deletions generated-files/container/HomeContainer/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import { initialState } from './reducer';
* Direct selector to the homeContainer state domain
*/

export const selectHomeContainerDomain = state => state.homeContainer || initialState
const selectHomeContainerDomain = state => state.homeContainer || initialState;

/**
* use createSelector if you are doing something with the returned state.
* https://redux.js.org/usage/deriving-data-selectors#createselector-overview
* e.g: const makeSelectHomeContainer = () =>
* createSelector(selectHomeContainerDomain, substate => get(substate, 'somevalue'))
*/

export default selectHomeContainerDomain
export const selectHomeContainer = () =>
createSelector(
selectHomeContainerDomain,
substate => substate,
);

This file was deleted.

13 changes: 0 additions & 13 deletions generated-files/container/HomeContainer/tests/actions.test.js

This file was deleted.

9 changes: 4 additions & 5 deletions generated-files/container/HomeContainer/tests/reducer.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// import produce from 'immer'
import { fromJS } from 'immutable';
import {
homeContainerReducer,
homeContainerTypes,
Expand All @@ -18,10 +17,10 @@ describe('HomeContainer 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(
homeContainerReducer(state, {
type: homeContainerTypes.DEFAULT_ACTION,
Expand Down
10 changes: 5 additions & 5 deletions generated-files/container/HomeContainer/tests/selectors.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { fromJS } from 'immutable';
import { selectHomeContainerDomain } from '../selectors';
import { selectHomeContainer } from '../selectors';

describe('HomeContainer selector tests', () => {
let mockedState;

beforeEach(() => {
mockedState = {
homeContainer: fromJS({}),
homeContainer: {},
};
});

it('should select the user state', () => {
expect(selectHomeContainerDomain(mockedState)).toEqual(
mockedState.homeContainer.toJS(),
const homeContainerSelector = selectHomeContainer();
expect(homeContainerSelector(mockedState)).toEqual(
mockedState.homeContainer,
);
});
});
5 changes: 3 additions & 2 deletions generators/container/selectors.test.js.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { select{{ properCase name }}Domain } from '../selectors'
import { select{{ properCase name }} } from '../selectors'

describe('{{ properCase name }} selector tests', () => {
let mockedState
Expand All @@ -10,6 +10,7 @@ describe('{{ properCase name }} selector tests', () => {
})

it('should select the user state', () => {
expect(select{{ properCase name }}Domain(mockedState)).toEqual(mockedState.{{ camelCase name }})
const {{ camelCase name }}Selector = select{{ properCase name }}();
expect({{ camelCase name }}Selector(mockedState)).toEqual(mockedState.{{ camelCase name }});
})
})

0 comments on commit dcbc0b9

Please sign in to comment.