-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0d9925
commit 75e8223
Showing
6 changed files
with
147 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @flow | ||
import invariant from 'tiny-invariant'; | ||
import type { Props } from './droppable-types'; | ||
|
||
export default (props: Props) => { | ||
invariant(props.droppableId, 'A Droppable requires a droppableId prop'); | ||
invariant( | ||
typeof props.isDropDisabled === 'boolean', | ||
'isDropDisabled must be a boolean', | ||
); | ||
invariant( | ||
typeof props.isCombineEnabled === 'boolean', | ||
'isCombineEnabled must be a boolean', | ||
); | ||
invariant( | ||
typeof props.ignoreContainerClipping === 'boolean', | ||
'ignoreContainerClipping must be a boolean', | ||
); | ||
}; |
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
63 changes: 63 additions & 0 deletions
63
test/unit/view/draggable/throw-if-invalid-own-props.spec.js
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,63 @@ | ||
// @flow | ||
import type { OwnProps } from '../../../../src/view/draggable/draggable-types'; | ||
import mount from './util/mount'; | ||
import { defaultOwnProps } from './util/get-props'; | ||
|
||
beforeAll(() => { | ||
jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
}); | ||
|
||
afterAll(() => { | ||
console.error.mockReset(); | ||
}); | ||
|
||
it('should throw if no draggableId is provided', () => { | ||
const ownProps: OwnProps = { | ||
...defaultOwnProps, | ||
}; | ||
// $ExpectError | ||
ownProps.draggableId = undefined; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
|
||
// $ExpectError | ||
ownProps.draggableId = null; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
|
||
// $ExpectError | ||
ownProps.draggableId = 0; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
}); | ||
|
||
it('should throw if no index is provided', () => { | ||
const ownProps: OwnProps = { | ||
...defaultOwnProps, | ||
}; | ||
// $ExpectError | ||
ownProps.index = undefined; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
|
||
// $ExpectError | ||
ownProps.index = null; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
}); | ||
|
||
it('should throw if the index is not an integer', () => { | ||
const ownProps: OwnProps = { | ||
...defaultOwnProps, | ||
}; | ||
// $ExpectError - string | ||
ownProps.index = 'what'; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
|
||
ownProps.index = 1.1; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
}); | ||
|
||
it('should throw if isDragDisabled is set to null', () => { | ||
const ownProps: OwnProps = { | ||
...defaultOwnProps, | ||
}; | ||
// $ExpectError - null | ||
ownProps.isDragDisabled = null; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
}); |
57 changes: 57 additions & 0 deletions
57
test/unit/view/droppable/throw-if-invalid-own-props.spec.js
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,57 @@ | ||
// @flow | ||
import type { OwnProps } from '../../../../src/view/droppable/droppable-types'; | ||
import mount from './util/mount'; | ||
import { ownProps as defaultOwnProps } from './util/get-props'; | ||
|
||
beforeAll(() => { | ||
jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
}); | ||
|
||
afterAll(() => { | ||
console.error.mockReset(); | ||
}); | ||
|
||
it('should throw if no droppableId is provided', () => { | ||
const ownProps: OwnProps = { | ||
...defaultOwnProps, | ||
}; | ||
|
||
// $ExpectError | ||
ownProps.droppableId = undefined; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
|
||
// $ExpectError | ||
ownProps.droppableId = null; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
|
||
// $ExpectError | ||
ownProps.droppableId = 0; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
}); | ||
|
||
it('should throw if isDropDisabled is set to null', () => { | ||
const ownProps: OwnProps = { | ||
...defaultOwnProps, | ||
}; | ||
// $ExpectError - null | ||
ownProps.isDropDisabled = null; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
}); | ||
|
||
it('should throw if isCombineEnabled is set to null', () => { | ||
const ownProps: OwnProps = { | ||
...defaultOwnProps, | ||
}; | ||
// $ExpectError - null | ||
ownProps.isCombineEnabled = null; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
}); | ||
|
||
it('should throw if ignoreContainerClipping is set to null', () => { | ||
const ownProps: OwnProps = { | ||
...defaultOwnProps, | ||
}; | ||
// $ExpectError - null | ||
ownProps.ignoreContainerClipping = null; | ||
expect(() => mount({ ownProps })).toThrow(); | ||
}); |