mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2026-03-14 06:22:48 +03:00
add userCounter mocks and rearrange webhook path
This commit is contained in:
@@ -5,8 +5,8 @@ import { getHash } from "../../src/utils/getHash";
|
||||
|
||||
|
||||
describe("userCounter", () => {
|
||||
it("Should return 200", (done) => {
|
||||
if (!config.userCounterURL) return done(); // skip if no userCounterURL is set
|
||||
it("Should return 200", function (done) {
|
||||
if (!config.userCounterURL) this.skip(); // skip if no userCounterURL is set
|
||||
axios.request({
|
||||
method: "POST",
|
||||
baseURL: config.userCounterURL,
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
import express from "express";
|
||||
import { config } from "../src/config";
|
||||
import { Server } from "http";
|
||||
import { UserCounter } from "./mocks/UserCounter";
|
||||
|
||||
const app = express();
|
||||
|
||||
app.post("/ReportChannelWebhook", (req, res) => {
|
||||
app.post("/webhook/ReportChannel", (req, res) => {
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
app.post("/FirstTimeSubmissionsWebhook", (req, res) => {
|
||||
app.post("/webhook/FirstTimeSubmissions", (req, res) => {
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
app.post("/CompletelyIncorrectReportWebhook", (req, res) => {
|
||||
app.post("/webhook/CompletelyIncorrectReport", (req, res) => {
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
// Testing NeuralBlock
|
||||
app.post("/NeuralBlockRejectWebhook", (req, res) => {
|
||||
app.post("/webhook/NeuralBlockReject", (req, res) => {
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
@@ -47,6 +48,9 @@ app.post("/CustomWebhook", (req, res) => {
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
// mocks
|
||||
app.use("/UserCounter", UserCounter);
|
||||
|
||||
export function createMockServer(callback: () => void): Server {
|
||||
return app.listen(config.mockPort, callback);
|
||||
}
|
||||
|
||||
11
test/mocks/UserCounter.ts
Normal file
11
test/mocks/UserCounter.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Router } from "express";
|
||||
export const UserCounter = Router();
|
||||
|
||||
UserCounter.post("/api/v1/addIP", (req, res) => {
|
||||
res.sendStatus(200);
|
||||
});
|
||||
UserCounter.get("/api/v1/userCount", (req, res) => {
|
||||
res.send({
|
||||
userCount: 100
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user