-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from Patreon/proptypes
Fix propTypes warning
- Loading branch information
Showing
4 changed files
with
59 additions
and
2 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,49 @@ | ||
import nion from '../' | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { mount } from 'enzyme' | ||
|
||
import { Provider } from 'react-redux' | ||
import configureTestStore from '../../../test/configure-test-store' | ||
|
||
describe('nion', () => { | ||
describe('propTypes validation', () => { | ||
let OuterComponent | ||
let originalConsoleError | ||
let store | ||
|
||
beforeAll(() => { | ||
originalConsoleError = global.console.error | ||
// Treat all console.errors as test failures to catch failed propType validation | ||
global.console.error = (...args) => { | ||
throw new Error(args[0]) | ||
} | ||
}) | ||
|
||
afterAll(() => { | ||
global.console.error = originalConsoleError | ||
}) | ||
|
||
beforeEach(() => { | ||
class WrappedComponent extends React.Component { | ||
static propTypes = { | ||
nion: PropTypes.object.isRequired, | ||
} | ||
|
||
render() { | ||
return null | ||
} | ||
} | ||
OuterComponent = nion()(WrappedComponent) | ||
store = configureTestStore() | ||
}) | ||
|
||
it('has no propTypes errors', () => { | ||
mount( | ||
<Provider store={store}> | ||
<OuterComponent /> | ||
</Provider>, | ||
) | ||
}) | ||
}) | ||
}) |
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