mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
This will help evaluate how much we are being rate limited, and on what routes it happens most.
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { Test, TestingModule } from "@nestjs/testing";
|
|
import { UrlValueParserService } from "./url-value-parser.service";
|
|
|
|
describe("UrlValueParserService", () => {
|
|
let service: UrlValueParserService;
|
|
|
|
beforeEach(async () => {
|
|
const module: TestingModule = await Test.createTestingModule({
|
|
providers: [UrlValueParserService],
|
|
}).compile();
|
|
|
|
service = module.get<UrlValueParserService>(UrlValueParserService);
|
|
});
|
|
|
|
it("should be defined", () => {
|
|
expect(service).toBeDefined();
|
|
});
|
|
|
|
describe("replacePathValues", () => {
|
|
it("works with default replacement", () => {
|
|
const replaced = service.replacePathValues(
|
|
"/in/world/14/userId/abca12d231"
|
|
);
|
|
expect(replaced).toBe("/in/world/#val/userId/#val");
|
|
});
|
|
|
|
it("works with custom replacement", () => {
|
|
const replaced = service.replacePathValues(
|
|
"/in/world/14/userId/abca12d231",
|
|
"<id>"
|
|
);
|
|
expect(replaced).toBe("/in/world/<id>/userId/<id>");
|
|
});
|
|
|
|
it("works with negative decimal numbers", () => {
|
|
const replaced = service.replacePathValues(
|
|
"/some/path/-154/userId/-ABC363AFE2"
|
|
);
|
|
expect(replaced).toBe("/some/path/#val/userId/-ABC363AFE2");
|
|
});
|
|
|
|
it("works with spotify ids", () => {
|
|
const replaced = service.replacePathValues(
|
|
"/v1/albums/2PzfMWIpq6JKucGhkS1X5M"
|
|
);
|
|
expect(replaced).toBe("/v1/albums/#val");
|
|
});
|
|
});
|
|
});
|