Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
test(ErrorLogger): add snapshot and configure jest mock
Browse files Browse the repository at this point in the history
Signed-off-by: Diana Lease <[email protected]>
  • Loading branch information
DianaLease committed May 9, 2019
1 parent 905975b commit bd5ef1a
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 2 deletions.
1 change: 1 addition & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
"jest": {
"setupFiles": [
"./src/utilities/test/jestEnzyme"
]
],
"moduleNameMapper": {
"\\.(css|scss|sass|styl)$": "<rootDir>/__mocks__/styleMock.js"
}
}
}
178 changes: 178 additions & 0 deletions src/ErrorLogger/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<ErrorLogger /> on initialization renders page correctly 1`] = `
<ReactTable
AggregatedComponent={[Function]}
ExpanderComponent={[Function]}
FilterComponent={[Function]}
LoadingComponent={[Function]}
NoDataComponent={[Function]}
PadRowComponent={[Function]}
PaginationComponent={[Function]}
PivotValueComponent={[Function]}
ResizerComponent={[Function]}
TableComponent={[Function]}
TbodyComponent={[Function]}
TdComponent={[Function]}
TfootComponent={[Function]}
ThComponent={[Function]}
TheadComponent={[Function]}
TrComponent={[Function]}
TrGroupComponent={[Function]}
aggregatedKey="_aggregated"
className=""
collapseOnDataChange={true}
collapseOnPageChange={true}
collapseOnSortingChange={true}
column={
Object {
"Aggregated": undefined,
"Cell": undefined,
"Expander": undefined,
"Filter": undefined,
"Footer": undefined,
"Header": undefined,
"Pivot": undefined,
"PivotValue": undefined,
"Placeholder": undefined,
"aggregate": undefined,
"className": "",
"filterAll": false,
"filterMethod": undefined,
"filterable": undefined,
"footerClassName": "",
"footerStyle": Object {},
"getFooterProps": [Function],
"getHeaderProps": [Function],
"getProps": [Function],
"headerClassName": "",
"headerStyle": Object {},
"minResizeWidth": 11,
"minWidth": 100,
"resizable": undefined,
"show": true,
"sortMethod": undefined,
"sortable": undefined,
"style": Object {},
}
}
columns={
Array [
Object {
"Header": "Type",
"accessor": "type",
"width": 100,
},
Object {
"Header": "Name",
"accessor": "name",
"width": 200,
},
Object {
"Header": "File",
"accessor": "fileName",
"width": 100,
},
Object {
"Header": "Start Location",
"accessor": [Function],
"id": "startLocation",
"width": 100,
},
Object {
"Header": "End Location",
"accessor": [Function],
"id": "endLocation",
"width": 100,
},
Object {
"Header": "Message",
"accessor": "shortMessage",
"width": 600,
},
]
}
data={Array []}
defaultExpanded={Object {}}
defaultFilterMethod={[Function]}
defaultFiltered={Array []}
defaultPage={0}
defaultPageSize={20}
defaultResized={Array []}
defaultSortDesc={false}
defaultSortMethod={[Function]}
defaultSorted={Array []}
expanderDefaults={
Object {
"filterable": false,
"resizable": false,
"sortable": false,
"width": 35,
}
}
filterable={false}
freezeWhenExpanded={false}
getLoadingProps={[Function]}
getNoDataProps={[Function]}
getPaginationProps={[Function]}
getProps={[Function]}
getResizerProps={[Function]}
getTableProps={[Function]}
getTbodyProps={[Function]}
getTdProps={[Function]}
getTfootProps={[Function]}
getTfootTdProps={[Function]}
getTfootTrProps={[Function]}
getTheadFilterProps={[Function]}
getTheadFilterThProps={[Function]}
getTheadFilterTrProps={[Function]}
getTheadGroupProps={[Function]}
getTheadGroupThProps={[Function]}
getTheadGroupTrProps={[Function]}
getTheadProps={[Function]}
getTheadThProps={[Function]}
getTheadTrProps={[Function]}
getTrGroupProps={[Function]}
getTrProps={[Function]}
groupedByPivotKey="_groupedByPivot"
indexKey="_index"
loading={false}
loadingText="Loading..."
multiSort={true}
nestingLevelKey="_nestingLevel"
nextText="Next"
noDataText="No rows found"
ofText="of"
onFetchData={[Function]}
originalKey="_original"
pageJumpText="jump to page"
pageSize={5}
pageSizeOptions={
Array [
5,
10,
20,
25,
50,
100,
]
}
pageText="Page"
pivotDefaults={Object {}}
pivotIDKey="_pivotID"
pivotValKey="_pivotVal"
previousText="Previous"
resizable={true}
resolveData={[Function]}
rowsSelectorText="rows per page"
rowsText="rows"
showPageJump={true}
showPageSizeOptions={true}
showPagination={true}
showPaginationBottom={true}
showPaginationTop={false}
sortable={true}
style={Object {}}
subRowsKey="_subRows"
/>
`;
2 changes: 1 addition & 1 deletion src/ErrorLogger/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import 'react-table/react-table.css';
import ReactTable from 'react-table';
import 'react-table/react-table.css';

/**
* @param {object} d
Expand Down
15 changes: 15 additions & 0 deletions src/ErrorLogger/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';

import ErrorLogger from './index';

describe('<ErrorLogger />', () => {
describe('on initialization', () => {
it('renders page correctly', () => {
const component = shallow(<ErrorLogger />);
const tree = toJson(component);
expect(tree).toMatchSnapshot();
});
});
});

0 comments on commit bd5ef1a

Please sign in to comment.