Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/components/App/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe("App", () => {
it("renders Loader when userProfile not loaded", () => {
const { container } = setup({
userProfile: {},
users: { list: null },
});
const app = container.querySelector(".loader");
expect(app).toBeInTheDocument();
Expand All @@ -23,7 +22,6 @@ describe("App", () => {
userProfile: {
username: "Steve",
},
users: { list: null },
});
const app = container.querySelector(".app");
expect(app).toBeInTheDocument();
Expand Down
5 changes: 1 addition & 4 deletions src/pages/LandingPage/LandingPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ const setup = (initialState = {}) =>

describe("LandingPage", () => {
it("renders", () => {
setup({
userProfile: {},
users: { list: null },
});
setup();

const heading = screen.getByText("Landing page");
expect(heading).toBeInTheDocument();
Expand Down
4 changes: 3 additions & 1 deletion src/state/rootReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { combineReducers } from "@reduxjs/toolkit";
import userProfile from "./userProfile/reducer";
import users from "./users/reducer";

const rootReducer = combineReducers({ userProfile, users });
export const reducers = { userProfile, users } as const;

const rootReducer = combineReducers(reducers);

export type RootState = ReturnType<typeof rootReducer>;
export default rootReducer;
4 changes: 2 additions & 2 deletions src/state/userProfile/selectors.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { getUsername } from "./selectors";

import mockState from "utilities/test/mockState";
import { RootState } from "../rootReducer";

describe("UserProfile selectors", () => {
describe("getUsername", () => {
it("should return username", () => {
const state: RootState = {
...mockState,
userProfile: {
username: "Steve",
},
users: { list: null },
};
expect(getUsername(state)).toBe("Steve");
});
Expand Down
9 changes: 9 additions & 0 deletions src/utilities/test/mockState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { initialState as userProfileInitialState } from "state/userProfile/reducer";
import { initialState as usersInitialState } from "state/users/reducer";

const state = {
userProfile: userProfileInitialState,
users: usersInitialState,
};

export default state;
4 changes: 3 additions & 1 deletion src/utilities/test/renderConnected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Provider } from "react-redux";
import configureStore, { MockStore } from "redux-mock-store";
import thunk from "redux-thunk";

import { reducers } from "state/rootReducer";

interface RenderConnected {
ui: JSX.Element;
initialState: Record<string, unknown>;
Expand All @@ -18,7 +20,7 @@ const middleware = [thunk];
const mockStore = configureStore(middleware);

export const makeStore = (initialState: Record<string, unknown>): MockStore =>
mockStore(initialState);
mockStore({ ...reducers, ...initialState });

const renderConnected = ({
ui,
Expand Down