36 lines
905 B
TypeScript
36 lines
905 B
TypeScript
import { describe, expect, test } from "vitest";
|
|
|
|
import { parseAuthorIds } from "../src/content/market/author-id-input";
|
|
|
|
describe("author-id-input", () => {
|
|
test("parses newline comma and space separated Xingtu author ids", () => {
|
|
expect(parseAuthorIds(`
|
|
6866044569306267651
|
|
7040323176106033165,7088592143119286285
|
|
7222310247979810854
|
|
`)).toEqual({
|
|
duplicates: [],
|
|
ids: [
|
|
"6866044569306267651",
|
|
"7040323176106033165",
|
|
"7088592143119286285",
|
|
"7222310247979810854"
|
|
],
|
|
invalidTokens: []
|
|
});
|
|
});
|
|
|
|
test("deduplicates ids and reports invalid tokens", () => {
|
|
expect(parseAuthorIds(`
|
|
6866044569306267651
|
|
bad-id
|
|
123
|
|
6866044569306267651
|
|
`)).toEqual({
|
|
duplicates: ["6866044569306267651"],
|
|
ids: ["6866044569306267651"],
|
|
invalidTokens: ["bad-id", "123"]
|
|
});
|
|
});
|
|
});
|