Skip to content

Commit

Permalink
refactor: dont use a magic string for USER_BASE_URL in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wescopeland committed Oct 18, 2022
1 parent 3793a57 commit 4f1a501
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 4 additions & 6 deletions src/user/getProfileFromAccountId.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
ProfileFromAccountIdResponse
} from "../models";
import { getProfileFromAccountId } from "./getProfileFromAccountId";
import { USER_BASE_URL } from "./USER_BASE_URL";

const server = setupServer();

Expand Down Expand Up @@ -71,12 +72,9 @@ describe("Function: getProfileFromUserName", () => {
};

server.use(
rest.get(
"https://m.np.playstation.com/api/userProfile/v1/internal/users/111222333444/profiles",
(_, res, ctx) => {
return res(ctx.json(mockResponse));
}
)
rest.get(`${USER_BASE_URL}/111222333444/profiles`, (_, res, ctx) => {
return res(ctx.json(mockResponse));
})
);

// ASSERT
Expand Down
10 changes: 4 additions & 6 deletions src/user/getUserFriendsAccountIds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
GetUserFriendsAccountIdsResponse
} from "../models";
import { getUserFriendsAccountIds } from "./getUserFriendsAccountIds";
import { USER_BASE_URL } from "./USER_BASE_URL";

const server = setupServer();

Expand All @@ -32,12 +33,9 @@ describe("Function: getUserFriendsAccountIds", () => {
};

server.use(
rest.get(
"https://m.np.playstation.com/api/userProfile/v1/internal/users/me/friends",
(_, res, ctx) => {
return res(ctx.json(mockResponse));
}
)
rest.get(`${USER_BASE_URL}/me/friends`, (_, res, ctx) => {
return res(ctx.json(mockResponse));
})
);

// ACT
Expand Down

1 comment on commit 4f1a501

@vercel
Copy link

@vercel vercel bot commented on 4f1a501 Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.