mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 07:37:55 -05:00
26 lines
789 B
TypeScript
26 lines
789 B
TypeScript
import { describe, expect, test } from "vitest";
|
|
import { assertRoundTrips } from "~/modules/search-params/search-params-test-utils";
|
|
import { chatUsersSearchParams } from "./chat-search-params";
|
|
|
|
describe("chatUsersSearchParams", () => {
|
|
test("round-trips", () => {
|
|
assertRoundTrips(chatUsersSearchParams, {
|
|
ids: [[], [1], [1, 2, 3]],
|
|
});
|
|
});
|
|
|
|
test("accepts the legacy comma-joined form", () => {
|
|
const { ids } = chatUsersSearchParams.parse(
|
|
new URL("http://localhost/api/chat-users?ids=1,2,3"),
|
|
);
|
|
expect(ids).toEqual([1, 2, 3]);
|
|
});
|
|
|
|
test("drops invalid members instead of the whole array", () => {
|
|
const { ids } = chatUsersSearchParams.parse(
|
|
new URL("http://localhost/api/chat-users?ids=1&ids=abc&ids=-5&ids=3"),
|
|
);
|
|
expect(ids).toEqual([1, 3]);
|
|
});
|
|
});
|