Refactor imports (#470)
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import * as appHooks from "@/app/hooks";
|
||||
import { AppDispatch } from "@/app/store";
|
||||
import HandleLogin from "@/features/User/HandleLogin";
|
||||
import * as oidcAuth from "@/features/User/oidcAuth";
|
||||
import { clientConfig } from "@/features/User/oidcAuth";
|
||||
import * as apiUtils from "@/utils/apiUtils";
|
||||
import { screen, waitFor } from "@testing-library/react";
|
||||
import thunk, { ThunkDispatch } from "redux-thunk";
|
||||
import HandleLogin from "../../../src/features/User/HandleLogin";
|
||||
import * as oidcAuth from "../../../src/features/User/oidcAuth";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
import { clientConfig } from "../../../src/features/User/oidcAuth";
|
||||
import * as apiUtils from "../../../src/utils/apiUtils";
|
||||
import * as appHooks from "../../../src/app/hooks";
|
||||
import { push } from "redux-first-history";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
|
||||
clientConfig.url = "https://example.com";
|
||||
|
||||
@@ -14,7 +14,7 @@ describe("HandleLogin", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
jest.spyOn(apiUtils, "redirectTo").mockImplementation(() => {});
|
||||
const dispatch = jest.fn() as ThunkDispatch<any, any, any>;
|
||||
const dispatch = jest.fn() as AppDispatch;
|
||||
jest.spyOn(appHooks, "useAppDispatch").mockReturnValue(dispatch);
|
||||
sessionStorage.clear();
|
||||
});
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
// __test__/features/user/CallbackResume.test.tsx
|
||||
import { render, waitFor } from "@testing-library/react";
|
||||
import { CallbackResume } from "../../../src/features/User/LoginCallback";
|
||||
import { useAppDispatch } from "../../../src/app/hooks";
|
||||
import * as oidcAuth from "../../../src/features/User/oidcAuth";
|
||||
import { push } from "redux-first-history";
|
||||
import { useAppDispatch } from "@/app/hooks";
|
||||
import { getCalendarsListAsync } from "@/features/Calendars/services/getCalendarsListAsync";
|
||||
import { CallbackResume } from "@/features/User/LoginCallback";
|
||||
import * as oidcAuth from "@/features/User/oidcAuth";
|
||||
import {
|
||||
getOpenPaasUserDataAsync,
|
||||
setTokens,
|
||||
setUserData,
|
||||
getOpenPaasUserDataAsync,
|
||||
} from "../../../src/features/User/userSlice";
|
||||
import { getCalendarsListAsync } from "../../../src/features/Calendars/services/getCalendarsListAsync";
|
||||
} from "@/features/User/userSlice";
|
||||
import { render, waitFor } from "@testing-library/react";
|
||||
import { push } from "redux-first-history";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
|
||||
// Mocks
|
||||
jest.mock("../../../src/app/hooks", () => ({
|
||||
jest.mock("@/app/hooks", () => ({
|
||||
useAppDispatch: jest.fn(),
|
||||
useAppSelector: jest.fn(() => ({})),
|
||||
}));
|
||||
|
||||
jest.mock("../../../src/features/User/oidcAuth", () => ({
|
||||
jest.mock("@/features/User/oidcAuth", () => ({
|
||||
Callback: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock("../../../src/features/User/userSlice", () => {
|
||||
jest.mock("@/features/User/userSlice", () => {
|
||||
const mockGetUser = Object.assign(
|
||||
jest.fn(() => ({ type: "GET_USER_ID" })),
|
||||
{
|
||||
@@ -39,23 +38,20 @@ jest.mock("../../../src/features/User/userSlice", () => {
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock(
|
||||
"../../../src/features/Calendars/services/getCalendarsListAsync",
|
||||
() => {
|
||||
const mockGetCalendars = Object.assign(
|
||||
jest.fn(() => ({ type: "GET_CALENDARS" })),
|
||||
{
|
||||
pending: { type: "GET_CALENDARS/pending" },
|
||||
fulfilled: { type: "GET_CALENDARS/fulfilled" },
|
||||
rejected: { type: "GET_CALENDARS/rejected" },
|
||||
}
|
||||
);
|
||||
jest.mock("@/features/Calendars/services/getCalendarsListAsync", () => {
|
||||
const mockGetCalendars = Object.assign(
|
||||
jest.fn(() => ({ type: "GET_CALENDARS" })),
|
||||
{
|
||||
pending: { type: "GET_CALENDARS/pending" },
|
||||
fulfilled: { type: "GET_CALENDARS/fulfilled" },
|
||||
rejected: { type: "GET_CALENDARS/rejected" },
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
getCalendarsListAsync: mockGetCalendars,
|
||||
};
|
||||
}
|
||||
);
|
||||
return {
|
||||
getCalendarsListAsync: mockGetCalendars,
|
||||
};
|
||||
});
|
||||
|
||||
describe("CallbackResume", () => {
|
||||
const dispatch = jest.fn();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// __tests__/auth.test.ts
|
||||
import * as client from "openid-client";
|
||||
import {
|
||||
Auth,
|
||||
Callback,
|
||||
clientConfig,
|
||||
getClientConfig,
|
||||
Auth,
|
||||
Logout,
|
||||
Callback,
|
||||
} from "../../../src/features/User/oidcAuth";
|
||||
import * as apiUtils from "../../../src/utils/apiUtils";
|
||||
} from "@/features/User/oidcAuth";
|
||||
import * as apiUtils from "@/utils/apiUtils";
|
||||
import * as client from "openid-client";
|
||||
|
||||
clientConfig.url = "https://example.com";
|
||||
const localAdress = "https://local.exemple.com";
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { clientConfig } from "../../../src/features/User/oidcAuth";
|
||||
import { clientConfig } from "@/features/User/oidcAuth";
|
||||
import {
|
||||
getOpenPaasUser,
|
||||
updateUserConfigurations,
|
||||
} from "../../../src/features/User/userAPI";
|
||||
import { api } from "../../../src/utils/apiUtils";
|
||||
} from "@/features/User/userAPI";
|
||||
import { api } from "@/utils/apiUtils";
|
||||
|
||||
jest.mock("../../../src/utils/apiUtils");
|
||||
jest.mock("@/utils/apiUtils");
|
||||
|
||||
clientConfig.url = "https://example.com";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user