Skip to content

Commit

Permalink
Merge pull request #281 from anuraghazra/master
Browse files Browse the repository at this point in the history
[pull] master from anuraghazra:master
  • Loading branch information
pull[bot] authored Nov 7, 2023
2 parents cf60803 + 843b15e commit 6bbc87b
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
// "arrow-body-style": [ "error", "always" ],
// "arrow-parens": [ "error", "always" ],
// "arrow-spacing": [ "error", { "before": true, "after": true }],
// "constructor-super": "error",
"constructor-super": "error",
// "generator-star-spacing": [ "error", "before" ],
// "no-arrow-condition": "error",
"no-class-assign": "error",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/empty-issues-closer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Run empty issues closer action
uses: rickstaa/empty-issues-closer-action@2ee9f86f16acb1d888a480f2080407d84248f475 # v1.1.39
uses: rickstaa/empty-issues-closer-action@37f2cd30a4fb97504bbb570dc73264cfa522dee3 # v1.1.40
env:
github_token: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/top-issues-dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Run top issues action
uses: rickstaa/top-issues-action@f72e408e2ca430a9d79620f27183d7fd85c7494a # v1.3.64
uses: rickstaa/top-issues-action@da2fb7f2bd61828135e0971f8d33efb1a079e9a9 # v1.3.65
env:
github_token: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
58 changes: 29 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@uppercod/css-to-object": "^1.1.1",
"axios-mock-adapter": "^1.22.0",
"color-contrast-checker": "^2.1.0",
"eslint": "^8.52.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"hjson": "^3.2.2",
"husky": "^8.0.3",
Expand Down
123 changes: 123 additions & 0 deletions tests/wakatime.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { jest } from "@jest/globals";
import "@testing-library/jest-dom";
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import wakatime from "../api/wakatime.js";
import { renderWakatimeCard } from "../src/cards/wakatime-card.js";
import { expect, it, describe, afterEach } from "@jest/globals";

const wakaTimeData = {
data: {
categories: [
{
digital: "22:40",
hours: 22,
minutes: 40,
name: "Coding",
percent: 100,
text: "22 hrs 40 mins",
total_seconds: 81643.570077,
},
],
daily_average: 16095,
daily_average_including_other_language: 16329,
days_including_holidays: 7,
days_minus_holidays: 5,
editors: [
{
digital: "22:40",
hours: 22,
minutes: 40,
name: "VS Code",
percent: 100,
text: "22 hrs 40 mins",
total_seconds: 81643.570077,
},
],
holidays: 2,
human_readable_daily_average: "4 hrs 28 mins",
human_readable_daily_average_including_other_language: "4 hrs 32 mins",
human_readable_total: "22 hrs 21 mins",
human_readable_total_including_other_language: "22 hrs 40 mins",
id: "random hash",
is_already_updating: false,
is_coding_activity_visible: true,
is_including_today: false,
is_other_usage_visible: true,
is_stuck: false,
is_up_to_date: true,
languages: [
{
digital: "0:19",
hours: 0,
minutes: 19,
name: "Other",
percent: 1.43,
text: "19 mins",
total_seconds: 1170.434361,
},
{
digital: "0:01",
hours: 0,
minutes: 1,
name: "TypeScript",
percent: 0.1,
text: "1 min",
total_seconds: 83.293809,
},
{
digital: "0:00",
hours: 0,
minutes: 0,
name: "YAML",
percent: 0.07,
text: "0 secs",
total_seconds: 54.975151,
},
],
operating_systems: [
{
digital: "22:40",
hours: 22,
minutes: 40,
name: "Mac",
percent: 100,
text: "22 hrs 40 mins",
total_seconds: 81643.570077,
},
],
percent_calculated: 100,
range: "last_7_days",
status: "ok",
timeout: 15,
total_seconds: 80473.135716,
total_seconds_including_other_language: 81643.570077,
user_id: "random hash",
username: "anuraghazra",
writes_only: false,
},
};

const mock = new MockAdapter(axios);

afterEach(() => {
mock.reset();
});

describe("Test /api/wakatime", () => {
it("should test the request", async () => {
const username = "anuraghazra";
const req = { query: { username } };
const res = { setHeader: jest.fn(), send: jest.fn() };
mock
.onGet(
`https://wakatime.com/api/v1/users/${username}/stats?is_including_today=true`,
)
.reply(200, wakaTimeData);

await wakatime(req, res);

expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(renderWakatimeCard(wakaTimeData.data, {}));
});
});

1 comment on commit 6bbc87b

@vercel
Copy link

@vercel vercel bot commented on 6bbc87b Nov 7, 2023

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.