-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into PE-917-webview-component-missing-test
- Loading branch information
Showing
12 changed files
with
993 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
61 changes: 61 additions & 0 deletions
61
ts/features/fims/history/components/__tests__/FimsHistoryKoScreen.test.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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { fireEvent } from "@testing-library/react-native"; | ||
import { createStore } from "redux"; | ||
import { applicationChangeState } from "../../../../../store/actions/application"; | ||
import { appReducer } from "../../../../../store/reducers"; | ||
import { GlobalState } from "../../../../../store/reducers/types"; | ||
import { renderScreenWithNavigationStoreContext } from "../../../../../utils/testWrapper"; | ||
import { FIMS_ROUTES } from "../../../common/navigation"; | ||
import { FimsHistoryKoScreen } from "../FimsHistoryKoScreen"; | ||
import * as NAVIGATION from "../../../../../navigation/params/AppParamsList"; | ||
import * as DISPATCH from "../../../../../store/hooks"; | ||
import { fimsHistoryGet } from "../../store/actions"; | ||
|
||
describe("fimshistoryKoScreen", () => { | ||
it("should match snapshot", () => { | ||
const component = renderComponent(); | ||
expect(component.toJSON()).toMatchSnapshot(); | ||
}); | ||
it("should go back on back press", () => { | ||
const mockBack = jest.fn(); | ||
jest.spyOn(NAVIGATION, "useIONavigation").mockImplementation( | ||
() => | ||
({ | ||
goBack: mockBack | ||
} as any) | ||
); | ||
const component = renderComponent(); | ||
expect(component).toBeDefined(); | ||
|
||
const button = component.getByTestId("test-back"); | ||
expect(button).toBeDefined(); | ||
|
||
fireEvent.press(button); | ||
expect(mockBack).toHaveBeenCalledTimes(1); | ||
}); | ||
it("should dispatch the correct retry action on retry press", () => { | ||
const mockDispatch = jest.fn(); | ||
jest | ||
.spyOn(DISPATCH, "useIODispatch") | ||
.mockImplementation(() => mockDispatch); | ||
|
||
const component = renderComponent(); | ||
expect(component).toBeDefined(); | ||
|
||
const button = component.getByTestId("test-retry"); | ||
expect(button).toBeDefined(); | ||
|
||
fireEvent.press(button); | ||
|
||
expect(mockDispatch).toHaveBeenCalledTimes(1); | ||
expect(mockDispatch).toHaveBeenCalledWith( | ||
fimsHistoryGet.request({ shouldReloadFromScratch: true }) | ||
); | ||
}); | ||
}); | ||
const renderComponent = () => | ||
renderScreenWithNavigationStoreContext<GlobalState>( | ||
FimsHistoryKoScreen, | ||
FIMS_ROUTES.HISTORY, | ||
{}, | ||
createStore(appReducer, applicationChangeState("active") as any) | ||
); |
Oops, something went wrong.