mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(api): 🎨 Finish Hono refactor
This commit is contained in:
parent
826a260e90
commit
959dd27ad6
20 changed files with 309 additions and 316 deletions
|
|
@ -16,6 +16,12 @@ afterAll(async () => {
|
|||
await deleteUsers();
|
||||
});
|
||||
|
||||
const getFormData = (object: Record<string, string | number | boolean>) =>
|
||||
Object.keys(object).reduce((formData, key) => {
|
||||
formData.append(key, String(object[key]));
|
||||
return formData;
|
||||
}, new FormData());
|
||||
|
||||
describe("API Tests", () => {
|
||||
describe("PATCH /api/v1/accounts/update_credentials", () => {
|
||||
test("should update the authenticated user's display name", async () => {
|
||||
|
|
@ -29,9 +35,8 @@ describe("API Tests", () => {
|
|||
method: "PATCH",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
body: getFormData({
|
||||
display_name: "New Display Name",
|
||||
}),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import { config } from "config-manager";
|
||||
import { getTestUsers, sendTestRequest, wrapRelativeUrl } from "~tests/utils";
|
||||
import type { Account as APIAccount } from "~types/mastodon/account";
|
||||
import type { AsyncAttachment as APIAsyncAttachment } from "~types/mastodon/async_attachment";
|
||||
import type { Context as APIContext } from "~types/mastodon/context";
|
||||
import type { Status as APIStatus } from "~types/mastodon/status";
|
||||
|
|
@ -60,13 +59,12 @@ describe("API Tests", () => {
|
|||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world!",
|
||||
visibility: "public",
|
||||
media_ids: [media1?.id],
|
||||
federate: false,
|
||||
"media_ids[]": media1?.id ?? "",
|
||||
federate: "false",
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
|
@ -108,13 +106,12 @@ describe("API Tests", () => {
|
|||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
body: new URLSearchParams({
|
||||
status: "This is a reply!",
|
||||
visibility: "public",
|
||||
in_reply_to_id: status?.id,
|
||||
federate: false,
|
||||
in_reply_to_id: status?.id ?? "",
|
||||
federate: "false",
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue