getStatus, token tests and mocks

This commit is contained in:
Michael C
2022-09-30 22:58:08 -04:00
parent 0b9e7029c5
commit 715d41fbb2
2 changed files with 29 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ import assert from "assert";
import { db } from "../../src/databases/databases";
import { client } from "../utils/httpClient";
import { config } from "../../src/config";
import sinon from "sinon";
let dbVersion: number;
describe("getStatus", () => {
@@ -122,4 +123,16 @@ describe("getStatus", () => {
})
.catch(err => done(err));
});
it("Should return commit unkown if not present", (done) => {
sinon.stub((global as any), "HEADCOMMIT").value(undefined);
client.get(`${endpoint}/commit`)
.then(res => {
assert.strictEqual(res.status, 200);
assert.strictEqual(res.data, "test"); // commit should be test
done();
})
.catch(err => done(err));
sinon.restore();
});
});