forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve utils coverage #11
Merged
oliviertassinari
merged 8 commits into
oliviertassinari:add-typescript-utils-coverage
from
eps1lon:pr/oliviertassinari/22367
Aug 31, 2020
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e9880f2
Fix chainPropTypes
eps1lon 7fec937
fix deepmerge
eps1lon cddfbec
stricter ref prop type validators
eps1lon 041ced9
stricter exactProp
eps1lon cf977b1
Explicit returntype for formatMuiErrorMessage
eps1lon 00e0a00
f exactProp
eps1lon 2f94177
better getDisplayName
eps1lon 9cbfaab
stricter HTMLElementType
eps1lon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,33 +1,35 @@ | ||
import { expect } from 'chai'; | ||
import exactProp, { specialProperty } from './exactProp'; | ||
import * as PropTypes from 'prop-types'; | ||
import exactProp from './exactProp'; | ||
|
||
describe('exactProp()', () => { | ||
const exactPropTypes = exactProp({ | ||
bar: {}, | ||
beforeEach(() => { | ||
PropTypes.resetWarningCache(); | ||
}); | ||
|
||
it('should have the right shape', () => { | ||
expect(typeof exactProp).to.equal('function'); | ||
expect(typeof exactPropTypes).to.equal('object'); | ||
it('should return null for supported props', () => { | ||
const props = { | ||
bar: false, | ||
}; | ||
const propTypes = { | ||
bar: PropTypes.bool, | ||
}; | ||
|
||
expect(() => { | ||
PropTypes.checkPropTypes(exactProp(propTypes), props, 'props', 'Component'); | ||
}).not.toErrorDev(); | ||
}); | ||
|
||
describe('exactPropTypes', () => { | ||
it('should return null for supported props', () => { | ||
const props = { | ||
bar: false, | ||
}; | ||
const result = exactPropTypes[specialProperty](props); | ||
expect(result).to.equal(null); | ||
}); | ||
it('should return an error for unsupported props', () => { | ||
const props = { | ||
foo: false, | ||
}; | ||
const propTypes = { | ||
bar: PropTypes.bool, | ||
}; | ||
|
||
it('should return an error for unsupported props', () => { | ||
const props = { | ||
foo: true, | ||
}; | ||
const result = exactPropTypes[specialProperty](props); | ||
expect(result.message).to.match( | ||
/The following props are not supported: `foo`. Please remove them/, | ||
); | ||
}); | ||
expect(() => { | ||
PropTypes.checkPropTypes(exactProp(propTypes), props, 'props', 'Component'); | ||
}).toErrorDev('The following props are not supported: `foo`. Please remove them'); | ||
}); | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this one, it should create an issue on
material-ui/packages/material-ui-utils/src/elementAcceptingRef.js
Lines 46 to 47 in 714dc1a
but at the same time, this looks completely safe:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PropTypes.Requireable<unknown>
means there already is aisRequred
which is not true. We only assign that later.