SponsorBlockServer/test/cases/userCounter.ts
Michael C 4438ce7db6
add genUser frameworks, start fixing tests
transformative:
- getUserID
- redisTest
- reputation

mocha test reconfig:
- etag
- getIP
- userCounter
- validateVideoIDs
2023-09-27 20:18:35 -04:00

27 lines
No EOL
1 KiB
TypeScript

import axios from "axios";
import assert from "assert";
import { config } from "../../src/config";
import { getHash } from "../../src/utils/getHash";
import { client } from "../utils/httpClient";
describe("userCounter", () => {
it("Should return 200", function () {
if (!config.userCounterURL) this.skip(); // skip if no userCounterURL is set
return axios.request({
method: "POST",
baseURL: config.userCounterURL,
url: "/api/v1/addIP",
params: {
hashedIP: getHash("127.0.0.1",1)
}
}).then(res => assert.strictEqual(res.status, 200));
});
it("Should not incremeent counter on OPTIONS", function () {
/* cannot spy test */
if (!config.userCounterURL) this.skip(); // skip if no userCounterURL is set
//const spy = sinon.spy(UserCounter);
return client({ method: "OPTIONS", url: "/api/status" })
.then(() => client({ method: "GET", url: "/api/status" }));
//assert.strictEqual(spy.callCount, 1);
});
});