mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 21:17:15 +03:00
add getStatus and cases
This commit is contained in:
25
test/cases/getStatus.ts
Normal file
25
test/cases/getStatus.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import assert from "assert";
|
||||
import fetch from "node-fetch";
|
||||
import {Done, getbaseURL} from "../utils";
|
||||
|
||||
import {db} from "../../src/databases/databases";
|
||||
let dbVersion: number;
|
||||
|
||||
describe("getStatus", () => {
|
||||
before(async () => {
|
||||
dbVersion = (await db.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value;
|
||||
});
|
||||
|
||||
it("Should be able to get status", (done: Done) => {
|
||||
fetch(`${getbaseURL()}/api/status`)
|
||||
.then(async res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = await res.json();
|
||||
assert.ok(data.uptime >= 1); // uptime should be greater than 1s
|
||||
assert.strictEqual(data.commit, "test");
|
||||
assert.strictEqual(data.db, Number(dbVersion));
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user