|
1 | 1 | import React from 'react'; |
| 2 | +import sinon from 'sinon'; |
2 | 3 | import { Notification } from '../src/index'; |
3 | 4 | import mockNotification from './mockNotification'; |
4 | 5 |
|
@@ -28,6 +29,39 @@ describe('<Notification />', () => { |
28 | 29 | const action = wrapper.find(actionClassName); |
29 | 30 | const title = wrapper.find(titleClassName); |
30 | 31 |
|
| 32 | + describe('title as React.PropTypes.node', () => { |
| 33 | + before(() => { |
| 34 | + // Since react will console.error propType warnings, |
| 35 | + // we stub console.error to raise an error |
| 36 | + // so the test runner will pick it up. |
| 37 | + sinon.stub(console, 'error').callsFake((warning) => { |
| 38 | + throw new Error(warning); |
| 39 | + }); |
| 40 | + }); |
| 41 | + |
| 42 | + after(() => { |
| 43 | + /* eslint-disable no-console */ |
| 44 | + console.error.restore(); |
| 45 | + /* eslint-enable no-console */ |
| 46 | + }); |
| 47 | + |
| 48 | + it('renders without error', () => { |
| 49 | + const icon = <i aria-hidden="true" className="warning" />; |
| 50 | + shallow( |
| 51 | + <Notification |
| 52 | + message={mockNotification.message} |
| 53 | + action={mockNotification.action} |
| 54 | + barStyle={mockNotification.barStyle} |
| 55 | + actionStyle={mockNotification.actionStyle} |
| 56 | + activeBarStyle={mockNotification.activeBarStyle} |
| 57 | + onClick={mockNotification.onClick} |
| 58 | + dismissAfter={mockNotification.dismissAfter} |
| 59 | + title={icon} |
| 60 | + /> |
| 61 | + ); |
| 62 | + }); |
| 63 | + }); |
| 64 | + |
31 | 65 | it('has the className `notification-bar`', () => { |
32 | 66 | expect(component).to.have.className('notification-bar'); |
33 | 67 | }); |
|
0 commit comments