Skip to content

Commit 841b9d0

Browse files
committed
fix broken tests from Oauth2 addition
1 parent b90b677 commit 841b9d0

3 files changed

Lines changed: 20 additions & 13 deletions

File tree

frontend/__tests__/account/login/login.test.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import { typePassword } from "../signup/signup.test";
77
import { submitDisabled } from "@/__tests__/utilities/TestingUtilities";
88
import { bkmkResp } from "@/__tests__/data/SampleData";
99
import { instance } from "@api/Api";
10-
import { instance as userInstance } from "@api/userApi";
1110
import authService from "@services/auth.service";
1211
import axios from "axios";
12+
import { userApiInstance } from "@api/userApi";
13+
const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL;
1314
const user = userEvent.setup();
15+
const userApiMock = new MockAdapter(userApiInstance);
16+
userApiMock.onGet("/oauth2Providers").reply(200, JSON.stringify([]));
1417

1518
describe("Login events.", () => {
1619
vi.mock("next/navigation", () => {
@@ -38,7 +41,6 @@ describe("Login events.", () => {
3841
const mock = new MockAdapter(axios);
3942

4043
// Create a custom response
41-
const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL;
4244
axiosMock.onGet().reply(200, bkmkResp);
4345

4446
const SIGNIN_URL = SERVER_URL + "/user/signin";
@@ -96,9 +98,9 @@ describe("Errors on fields.", () => {
9698
});
9799
});
98100

99-
describe("Oauth2 Signin", () => {
100-
beforeEach(() => {
101-
render(<Page />);
102-
});
103-
test("Oauth2Providers are listed", async () => {});
104-
});
101+
// describe("Oauth2 Signin", () => {
102+
// beforeEach(() => {
103+
// render(<Page />);
104+
// });
105+
// test("Oauth2Providers are listed", async () => {});
106+
// });

frontend/api/Api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ instance.interceptors.response.use(
4646
);
4747

4848
export function parseData(data: string) {
49-
if (data.length != 0 || data || data != "") {
49+
if (data === undefined || data === "") {
50+
return null;
51+
}
52+
53+
if (data || data.length != 0) {
5054
return JSON.parse(data);
5155
}
56+
5257
return data;
5358
}
5459

frontend/api/userApi.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import axios from "axios";
22
import { parseData } from "./Api";
33
const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL + "/user";
44

5-
export const instance = axios.create({
5+
export const userApiInstance = axios.create({
66
withCredentials: true,
77
baseURL: SERVER_URL,
88
timeout: 10000,
@@ -20,19 +20,19 @@ const userApi = {
2020
data: any,
2121
config: {} | undefined,
2222
) {
23-
return instance({
23+
return userApiInstance({
2424
method: method,
2525
url: resource,
2626
data,
2727
...config,
2828
});
2929
},
3030
userInfo() {
31-
return instance.get("/user-info");
31+
return userApiInstance.get("/user-info");
3232
},
3333
oauth2Providers() {
3434
console.log("getOauth2Providers");
35-
return instance.get("/oauth2Providers");
35+
return userApiInstance.get("/oauth2Providers");
3636
},
3737
};
3838

0 commit comments

Comments
 (0)