Repository: anuraghazra/github-readme-stats
Pull request #3443 (2023-10-29 20:48:44)

tests(stats card): cover with test changes in #3298

vercel[bot]: [vc]: #q1KjX0+uNM/MUzMlKeCAz2LM2J8MXzju6lYIZWty5FY=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJnaXRodWItcmVhZG1lLXN0YXRzIiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL2dpdGh1Yi1yZWFkbWUtc3RhdHMtdGVhbS9naXRodWItcmVhZG1lLXN0YXRzL0ZkdXNjTEhqTDVnWnFXbVZnUzk5Smk1RVdEaGIiLCJwcmV2aWV3VXJsIjoiZ2l0aHViLXJlYWRtZS1zdGF0cy1naXQtdGVzdHNhZC0wNjIxMzAtZ2l0aHViLXJlYWRtZS1zdGF0cy10ZWFtLnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiUEVORElORyJ9XX0=
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Updated (UTC) |
| :--- | :----- | :------ | :------ |
| **github-readme-stats** | 🔄 Building ([Inspect](https://vercel.com/github-readme-stats-team/github-readme-stats/FduscLHjL5gZqWmVgS99Ji5EWDhb)) | [Visit Preview](https://github-readme-stats-git-testsad-062130-github-readme-stats-team.vercel.app) | Oct 29, 2023 8:48pm |


codecov[bot]: We're currently processing your upload.  This comment will be updated when the results are available.

Patch:
diff --git a/api/index.js b/api/index.js
index e1e1c27..2029367 100644
--- a/api/index.js
+++ b/api/index.js
@@ -43,7 +43,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,
diff --git a/api/pin.js b/api/pin.js
index bdad925..c67df29 100644
--- a/api/pin.js
+++ b/api/pin.js
@@ -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,
diff --git a/api/top-langs.js b/api/top-langs.js
index 0ca96fe..382ee42 100644
--- a/api/top-langs.js
+++ b/api/top-langs.js
@@ -38,7 +38,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,


Test patch:
diff --git a/tests/api.test.js b/tests/api.test.js
index a6ed04b..eee9a1a 100644
--- a/tests/api.test.js
+++ b/tests/api.test.js
@@ -120,6 +120,21 @@ describe("Test /api/", () => {
     );
   });
 
+  it("should render error card in same theme as requested card", async () => {
+    const { req, res } = faker({ theme: "merko" }, error);
+
+    await api(req, res);
+
+    expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
+    expect(res.send).toBeCalledWith(
+      renderError(
+        error.errors[0].message,
+        "Make sure the provided username is not an organization",
+        { theme: "merko" },
+      ),
+    );
+  });
+
   it("should get the query options", async () => {
     const { req, res } = faker(
       {
@@ -291,7 +306,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 () => {
diff --git a/tests/pin.test.js b/tests/pin.test.js
index 0dcb5aa..105e445 100644
--- a/tests/pin.test.js
+++ b/tests/pin.test.js
@@ -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 () => {
diff --git a/tests/top-langs.test.js b/tests/top-langs.test.js
index 272ee7e..692681b 100644
--- a/tests/top-langs.test.js
+++ b/tests/top-langs.test.js
@@ -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 () => {