Adding tests for RavenBoundary

This commit is contained in:
Jeff Avallone 2018-02-11 12:13:15 -05:00
parent edf4ecd081
commit e0716ef683
2 changed files with 55 additions and 0 deletions

View 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();
});
});

View 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 />`;