-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update InformationRequirementsTablePage.spec.tsx to give a more usefu…
…l snap
- Loading branch information
Showing
3 changed files
with
97 additions
and
22 deletions.
There are no files selected for viewing
56 changes: 49 additions & 7 deletions
56
...onents/project/informationRequirementsTablePage/InformationRequirementsTablePage.spec.tsx
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 |
---|---|---|
@@ -1,26 +1,68 @@ | ||
import React from "react"; | ||
import { shallow } from "enzyme"; | ||
import { InformationRequirementsTablePage } from "@/components/pages/Project/InformationRequirementsTablePage"; | ||
import * as MOCK from "@/tests/mocks/dataMocks"; | ||
import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; | ||
import { PROJECTS } from "@mds/common/constants/reducerTypes"; | ||
import * as reducerTypes from "@mds/common/constants/reducerTypes"; | ||
import { AUTHENTICATION, PROJECTS } from "@mds/common/constants/reducerTypes"; | ||
import { render } from "@testing-library/react"; | ||
import { USER_ROLES } from "@mds/common"; | ||
import { Provider } from "react-redux"; | ||
import { store } from "@/App"; | ||
import * as projectActionCreator from "@mds/common/redux/actionCreators/projectActionCreator"; | ||
import { AppThunk } from "@mds/common/interfaces/appThunk.type"; | ||
import { success } from "@mds/common/redux/actions/genericActions"; | ||
import * as projectActions from "@mds/common/redux/actions/projectActions"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
|
||
const initialState = { | ||
[PROJECTS]: { | ||
projects: [MOCK.PROJECT], | ||
project: MOCK.PROJECT, | ||
requirements: MOCK.INFORMATION_REQUIREMENTS_TABLE.requirements, | ||
informationRequirementsTableDocumentTypesHash: | ||
MOCK.INFORMATION_REQUIREMENTS_TABLE_STATUS_CODES_HASH, | ||
}, | ||
[AUTHENTICATION]: { | ||
userAccessData: [USER_ROLES.role_minespace_proponent], | ||
}, | ||
}; | ||
|
||
function mockFunction() { | ||
const original = jest.requireActual("react-router-dom"); | ||
const projectGuid = "8132462392222"; | ||
const irtGuid = "c16afb82-144c-4138-9a36-ba5c24c43d8a"; | ||
return { | ||
...original, | ||
useParams: jest.fn().mockReturnValue({ | ||
projectGuid, | ||
irtGuid, | ||
}), | ||
useLocation: jest.fn().mockReturnValue({ | ||
state: { current: 0 }, | ||
}), | ||
}; | ||
} | ||
|
||
jest.mock("react-router-dom", () => mockFunction()); | ||
jest.spyOn(projectActionCreator, "fetchProjectById").mockImplementation( | ||
(): AppThunk<Promise<any>> => (dispatch) => { | ||
dispatch(success(reducerTypes.GET_PROJECT)); | ||
dispatch(projectActions.storeProject(MOCK.PROJECT)); | ||
return Promise.resolve(MOCK.PROJECT); | ||
} | ||
); | ||
describe("InformationRequirementsTablePage", () => { | ||
it("renders properly", () => { | ||
const component = shallow( | ||
<ReduxWrapper initialState={initialState}> | ||
<InformationRequirementsTablePage /> | ||
</ReduxWrapper> | ||
const { container } = render( | ||
<BrowserRouter> | ||
<ReduxWrapper initialState={initialState}> | ||
<Provider store={store}> | ||
<InformationRequirementsTablePage /> | ||
</Provider> | ||
</ReduxWrapper> | ||
</BrowserRouter> | ||
); | ||
expect(component).toMatchSnapshot(); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
16 changes: 1 addition & 15 deletions
16
...rmationRequirementsTablePage/__snapshots__/InformationRequirementsTablePage.spec.tsx.snap
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 |
---|---|---|
@@ -1,17 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`InformationRequirementsTablePage renders properly 1`] = ` | ||
<Provider | ||
store={ | ||
Object { | ||
"@@observable": [Function], | ||
"dispatch": [Function], | ||
"getState": [Function], | ||
"replaceReducer": [Function], | ||
"subscribe": [Function], | ||
} | ||
} | ||
> | ||
<InformationRequirementsTablePage /> | ||
</Provider> | ||
`; | ||
exports[`InformationRequirementsTablePage renders properly 1`] = `<div />`; |
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