mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 23:58:36 -05:00
User search (#1468)
* Initial * Search users from API * Better feeling search * Fix TODO * Search via url, discord id & id * Load initial user * UserSearch on admin page * UserSearch on tournaments page * UserSearch for badges * Plus suggestions * Vod page * Remove unused code * Fix test
This commit is contained in:
44
app/utils/users.test.ts
Normal file
44
app/utils/users.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { suite } from "uvu";
|
||||
import * as assert from "uvu/assert";
|
||||
import { queryToUserIdentifier } from "./users";
|
||||
|
||||
const QueryToUserIdentifier = suite("queryToUserIdentifier()");
|
||||
|
||||
QueryToUserIdentifier("returns null if no match", () => {
|
||||
assert.equal(queryToUserIdentifier("foo"), null);
|
||||
});
|
||||
|
||||
QueryToUserIdentifier("gets custom url from url", () => {
|
||||
assert.equal(queryToUserIdentifier("https://sendou.ink/u/sendou"), {
|
||||
customUrl: "sendou",
|
||||
});
|
||||
});
|
||||
|
||||
QueryToUserIdentifier("gets discord id from url", () => {
|
||||
assert.equal(
|
||||
queryToUserIdentifier("https://sendou.ink/u/79237403620945920"),
|
||||
{
|
||||
discordId: "79237403620945920",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
QueryToUserIdentifier("gets custom url from url (without https://)", () => {
|
||||
assert.equal(queryToUserIdentifier("sendou.ink/u/sendou"), {
|
||||
customUrl: "sendou",
|
||||
});
|
||||
});
|
||||
|
||||
QueryToUserIdentifier("gets discord id", () => {
|
||||
assert.equal(queryToUserIdentifier("79237403620945920"), {
|
||||
discordId: "79237403620945920",
|
||||
});
|
||||
});
|
||||
|
||||
QueryToUserIdentifier("gets id", () => {
|
||||
assert.equal(queryToUserIdentifier("1"), {
|
||||
id: 1,
|
||||
});
|
||||
});
|
||||
|
||||
QueryToUserIdentifier.run();
|
||||
Reference in New Issue
Block a user