mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Add reblog and unreblog endpoints
This commit is contained in:
parent
5bba96435c
commit
ca94c35bc4
9 changed files with 368 additions and 7 deletions
|
|
@ -503,6 +503,56 @@ describe("API Tests", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("DELETE /api/v1/profile/avatar", () => {
|
||||
test("should delete the avatar of the authenticated user and return the updated account object", async () => {
|
||||
const response = await fetch(
|
||||
`${config.http.base_url}/api/v1/profile/avatar`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token.access_token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.headers.get("content-type")).toBe(
|
||||
"application/json"
|
||||
);
|
||||
|
||||
const account = (await response.json()) as APIAccount;
|
||||
|
||||
expect(account.id).toBeDefined();
|
||||
expect(account.avatar).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("DELETE /api/v1/profile/header", () => {
|
||||
test("should delete the header of the authenticated user and return the updated account object", async () => {
|
||||
const response = await fetch(
|
||||
`${config.http.base_url}/api/v1/profile/header`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token.access_token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.headers.get("content-type")).toBe(
|
||||
"application/json"
|
||||
);
|
||||
|
||||
const account = (await response.json()) as APIAccount;
|
||||
|
||||
expect(account.id).toBeDefined();
|
||||
expect(account.header).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("GET /api/v1/accounts/familiar_followers", () => {
|
||||
test("should follow the user", async () => {
|
||||
const response = await fetch(
|
||||
|
|
|
|||
|
|
@ -200,6 +200,57 @@ describe("API Tests", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("POST /api/v1/statuses/:id/reblog", () => {
|
||||
test("should reblog the specified status and return the reblogged status object", async () => {
|
||||
const response = await fetch(
|
||||
`${config.http.base_url}/api/v1/statuses/${status?.id}/reblog`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token.access_token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.headers.get("content-type")).toBe(
|
||||
"application/json"
|
||||
);
|
||||
|
||||
const rebloggedStatus = (await response.json()) as APIStatus;
|
||||
|
||||
expect(rebloggedStatus.id).toBeDefined();
|
||||
expect(rebloggedStatus.reblog?.id).toEqual(status?.id ?? "");
|
||||
expect(rebloggedStatus.reblog?.reblogged).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("POST /api/v1/statuses/:id/unreblog", () => {
|
||||
test("should unreblog the specified status and return the original status object", async () => {
|
||||
const response = await fetch(
|
||||
`${config.http.base_url}/api/v1/statuses/${status?.id}/unreblog`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token.access_token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.headers.get("content-type")).toBe(
|
||||
"application/json"
|
||||
);
|
||||
|
||||
const unrebloggedStatus = (await response.json()) as APIStatus;
|
||||
|
||||
expect(unrebloggedStatus.id).toBeDefined();
|
||||
expect(unrebloggedStatus.reblogged).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("GET /api/v1/statuses/:id/context", () => {
|
||||
test("should return the context of the specified status", async () => {
|
||||
const response = await fetch(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue