-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flashMessageType for propType checking (#8)
* Add flashMessageType * Update readme * v1.2.0
- Loading branch information
Showing
8 changed files
with
134 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import PropTypes from 'prop-types' | ||
|
||
const flashMessageType = PropTypes.shape({ | ||
id: PropTypes.string.isRequired, | ||
message: PropTypes.string.isRequired, | ||
isError: PropTypes.bool.isRequired, | ||
props: PropTypes.object.isRequired, | ||
}) | ||
|
||
export default flashMessageType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import PropTypes from 'prop-types' | ||
import { | ||
flashMessage, | ||
flashMessageType, | ||
} from '../src' | ||
import configureStore from './mockStore' | ||
import thunkMiddleware from 'redux-thunk' | ||
|
||
const mockStore = configureStore([ thunkMiddleware ]) | ||
|
||
function validatePropType (propType, value) { | ||
// checkPropTypes will log an error if it fails | ||
const spy = jest.spyOn(console, 'error') | ||
PropTypes.checkPropTypes({ value: propType }, { value }, 'prop') | ||
expect(spy).not.toHaveBeenCalled() | ||
} | ||
|
||
test('propTypes match flash message object shape', () => { | ||
const store = mockStore({}) | ||
store.dispatch(flashMessage('Hi')) | ||
// Get generated flash message | ||
const messageObject = store.getActions().pop().payload | ||
return validatePropType(flashMessageType, messageObject) | ||
}) |
File renamed without changes.
Oops, something went wrong.