Adding tests for RavenBoundary
This commit is contained in:
parent
edf4ecd081
commit
e0716ef683
32
src/components/RavenBoundary.test.js
Normal file
32
src/components/RavenBoundary.test.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { shallow } from 'enzyme';
|
||||||
|
|
||||||
|
import RavenBoundary from './RavenBoundary';
|
||||||
|
|
||||||
|
const testError = { error: 'test error' };
|
||||||
|
const testDetails = { details: 'test details' };
|
||||||
|
|
||||||
|
describe('RavenBoundary', () => {
|
||||||
|
test('rendering', () => {
|
||||||
|
const Child = () => <b>Child</b>;
|
||||||
|
const component = shallow(
|
||||||
|
<RavenBoundary>
|
||||||
|
<Child/>
|
||||||
|
</RavenBoundary>
|
||||||
|
);
|
||||||
|
expect(component).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('rendering (with error)', () => {
|
||||||
|
const Child = () => <b>Child</b>;
|
||||||
|
const component = shallow(
|
||||||
|
<RavenBoundary>
|
||||||
|
<Child/>
|
||||||
|
</RavenBoundary>
|
||||||
|
);
|
||||||
|
expect(component).toMatchSnapshot();
|
||||||
|
component.instance().componentDidCatch(testError, testDetails);
|
||||||
|
component.update();
|
||||||
|
expect(component).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
23
src/components/__snapshots__/RavenBoundary.test.js.snap
Normal file
23
src/components/__snapshots__/RavenBoundary.test.js.snap
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`RavenBoundary rendering (with error) 1`] = `<Child />`;
|
||||||
|
|
||||||
|
exports[`RavenBoundary rendering (with error) 2`] = `
|
||||||
|
<RavenError
|
||||||
|
details={
|
||||||
|
Object {
|
||||||
|
"extra": Object {
|
||||||
|
"details": "test details",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
error={
|
||||||
|
Object {
|
||||||
|
"error": "test error",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
heading="An error has occurred."
|
||||||
|
/>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`RavenBoundary rendering 1`] = `<Child />`;
|
Loading…
Reference in New Issue
Block a user