SponsorBlockServer/test/cases/getTotalStats.ts

39 lines
1.5 KiB
TypeScript
Raw Normal View History

2022-09-21 05:22:21 +02:00
import assert from "assert";
import { client } from "../utils/httpClient";
const endpoint = "/api/getTotalStats";
describe("getTotalStats", () => {
it("Can get total stats", async () => {
const result = await client({ url: endpoint });
const data = result.data;
2023-02-21 04:56:38 +01:00
assert.strictEqual(data.userCount, 0, "User count should default false");
2022-09-21 05:22:21 +02:00
assert.ok(data.activeUsers >= 0);
assert.ok(data.apiUsers >= 0);
assert.ok(data.viewCount >= 0);
assert.ok(data.totalSubmissions >= 0);
assert.ok(data.minutesSaved >= 0);
});
2023-02-21 04:21:46 +01:00
it("Can get total stats without contributing users", async () => {
const result = await client({ url: `${endpoint}?countContributingUsers=false` });
const data = result.data;
assert.strictEqual(data.userCount, 0);
assert.ok(data.activeUsers >= 0);
assert.ok(data.apiUsers >= 0);
assert.ok(data.viewCount >= 0);
assert.ok(data.totalSubmissions >= 0);
assert.ok(data.minutesSaved >= 0);
});
2023-02-22 02:09:38 +01:00
it("Can get total stats with contributing users", async () => {
2023-02-21 04:56:38 +01:00
const result = await client({ url: `${endpoint}?countContributingUsers=true` });
2023-02-21 04:21:46 +01:00
const data = result.data;
2023-02-21 04:56:38 +01:00
assert.ok(data.userCount >= 0);
2023-02-21 04:21:46 +01:00
assert.ok(data.activeUsers >= 0);
assert.ok(data.apiUsers >= 0);
assert.ok(data.viewCount >= 0);
assert.ok(data.totalSubmissions >= 0);
assert.ok(data.minutesSaved >= 0);
});
2022-09-21 05:22:21 +02:00
});