Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
Add test coverage for invalid validator warning (#86)
Browse files Browse the repository at this point in the history
* Add test coverage for invalid validator warning

* Fix invalid validator test name
  • Loading branch information
aweary authored Jul 19, 2017
1 parent 42d559d commit 0445b8b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions __tests__/PropTypesDevelopmentReact15.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@ describe('PropTypesDevelopmentReact15', () => {
});

describe('checkPropTypes', () => {
it('should warn for invalid validators', () => {
spyOn(console, 'error')
const propTypes = { foo: undefined };
const props = { foo: 'foo' };
PropTypes.checkPropTypes(
propTypes,
props,
'prop',
'testComponent',
null,
);
expect(console.error.calls.argsFor(0)[0]).toEqual(
'Warning: Failed prop type: testComponent: prop type `foo` is invalid; ' +
'it must be a function, usually from the `prop-types` package.'
);
});

it('does not return a value from a validator', () => {
spyOn(console, 'error');
const propTypes = {
Expand Down
17 changes: 17 additions & 0 deletions __tests__/PropTypesDevelopmentStandalone-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,23 @@ describe('PropTypesDevelopmentStandalone', () => {
});

describe('checkPropTypes', () => {
it('should warn for invalid validators', () => {
spyOn(console, 'error')
const propTypes = { foo: undefined };
const props = { foo: 'foo' };
PropTypes.checkPropTypes(
propTypes,
props,
'prop',
'testComponent',
null,
);
expect(console.error.calls.argsFor(0)[0]).toEqual(
'Warning: Failed prop type: testComponent: prop type `foo` is invalid; ' +
'it must be a function, usually from the `prop-types` package.'
);
});

it('does not return a value from a validator', () => {
spyOn(console, 'error');
const propTypes = {
Expand Down

0 comments on commit 0445b8b

Please sign in to comment.