Skip to content

Commit

Permalink
refactor: improve blacklisted username error by adding secondary mess…
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty541 authored and jacobbexten committed Nov 6, 2024
1 parent e049f61 commit 71df145
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default async (req, res) => {

if (blacklist.includes(username)) {
return res.send(
renderError("Something went wrong", "", {
renderError("Something went wrong", "This username is blacklisted", {
title_color,
text_color,
bg_color,
Expand Down
2 changes: 1 addition & 1 deletion api/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default async (req, res) => {

if (blacklist.includes(username)) {
return res.send(
renderError("Something went wrong", "", {
renderError("Something went wrong", "This username is blacklisted", {
title_color,
text_color,
bg_color,
Expand Down
2 changes: 1 addition & 1 deletion api/top-langs.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default async (req, res) => {

if (blacklist.includes(username)) {
return res.send(
renderError("Something went wrong", "", {
renderError("Something went wrong", "This username is blacklisted", {
title_color,
text_color,
bg_color,
Expand Down
4 changes: 3 additions & 1 deletion tests/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ describe("Test /api/", () => {
await api(req, res);

expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(renderError("Something went wrong"));
expect(res.send).toBeCalledWith(
renderError("Something went wrong", "This username is blacklisted"),
);
});

it("should render error card when wrong locale is provided", async () => {
Expand Down
4 changes: 3 additions & 1 deletion tests/pin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ describe("Test /api/pin", () => {
await pin(req, res);

expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(renderError("Something went wrong"));
expect(res.send).toBeCalledWith(
renderError("Something went wrong", "This username is blacklisted"),
);
});

it("should render error card if wrong locale provided", async () => {
Expand Down
4 changes: 3 additions & 1 deletion tests/top-langs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ describe("Test /api/top-langs", () => {
await topLangs(req, res);

expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(renderError("Something went wrong"));
expect(res.send).toBeCalledWith(
renderError("Something went wrong", "This username is blacklisted"),
);
});

it("should render error card if wrong locale provided", async () => {
Expand Down

0 comments on commit 71df145

Please sign in to comment.