-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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 #4347 from oliviertassinari/picker-improve-proptypes
[Pickers] Add some test regarding the expect value property
- Loading branch information
Showing
4 changed files
with
105 additions
and
10 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,42 @@ | ||
/* eslint-env mocha */ | ||
import React from 'react'; | ||
import {shallow} from 'enzyme'; | ||
import {assert} from 'chai'; | ||
import {stub} from 'sinon'; | ||
import DatePicker from './DatePicker'; | ||
import getMuiTheme from '../styles/getMuiTheme'; | ||
|
||
describe('<DatePicker />', () => { | ||
const muiTheme = getMuiTheme(); | ||
const shallowWithContext = (node) => shallow(node, {context: {muiTheme}}); | ||
|
||
describe('propTypes', () => { | ||
let consoleStub; | ||
|
||
beforeEach(() => { | ||
consoleStub = stub(console, 'error'); | ||
}); | ||
|
||
afterEach(() => { | ||
console.error.restore(); // eslint-disable-line no-console | ||
}); | ||
|
||
it('should throw when using wrong properties', () => { | ||
shallowWithContext( | ||
<DatePicker value="2016-03-21" /> | ||
); | ||
assert.strictEqual(consoleStub.callCount, 1); | ||
assert.strictEqual( | ||
consoleStub.args[0][0], | ||
'Warning: Failed propType: Invalid prop `value` of type `string` supplied to `DatePicker`, expected `object`.' | ||
); | ||
}); | ||
|
||
it('should not throw when using a valid properties', () => { | ||
shallowWithContext( | ||
<DatePicker value={new Date()} /> | ||
); | ||
assert.strictEqual(consoleStub.callCount, 0); | ||
}); | ||
}); | ||
}); |
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,42 @@ | ||
/* eslint-env mocha */ | ||
import React from 'react'; | ||
import {shallow} from 'enzyme'; | ||
import {assert} from 'chai'; | ||
import {stub} from 'sinon'; | ||
import TimePicker from './TimePicker'; | ||
import getMuiTheme from '../styles/getMuiTheme'; | ||
|
||
describe('<TimePicker />', () => { | ||
const muiTheme = getMuiTheme(); | ||
const shallowWithContext = (node) => shallow(node, {context: {muiTheme}}); | ||
|
||
describe('propTypes', () => { | ||
let consoleStub; | ||
|
||
beforeEach(() => { | ||
consoleStub = stub(console, 'error'); | ||
}); | ||
|
||
afterEach(() => { | ||
console.error.restore(); // eslint-disable-line no-console | ||
}); | ||
|
||
it('should throw when using wrong properties', () => { | ||
shallowWithContext( | ||
<TimePicker value="2016-03-21" /> | ||
); | ||
assert.strictEqual(consoleStub.callCount, 1); | ||
assert.strictEqual( | ||
consoleStub.args[0][0], | ||
'Warning: Failed propType: Invalid prop `value` of type `string` supplied to `TimePicker`, expected `object`.' | ||
); | ||
}); | ||
|
||
it('should not throw when using a valid properties', () => { | ||
shallowWithContext( | ||
<TimePicker value={new Date()} /> | ||
); | ||
assert.strictEqual(consoleStub.callCount, 0); | ||
}); | ||
}); | ||
}); |