mirror of
https://github.com/versia-pub/server.git
synced 2026-01-26 04:06:01 +01:00
test(api): ✅ Add more tests for favourite and unfavourite
This commit is contained in:
parent
1d55570abd
commit
268ced27ef
|
|
@ -52,4 +52,27 @@ describe(meta.route, () => {
|
|||
expect(json.favourited).toBe(true);
|
||||
expect(json.favourites_count).toBe(1);
|
||||
});
|
||||
|
||||
test("post should be favourited when fetched", async () => {
|
||||
const response = await sendTestRequest(
|
||||
new Request(
|
||||
new URL(
|
||||
`/api/v1/statuses/${timeline[0].id}`,
|
||||
config.http.base_url,
|
||||
),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
const json = (await response.json()) as APIStatus;
|
||||
|
||||
expect(json.favourited).toBe(true);
|
||||
expect(json.favourites_count).toBe(1);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -88,4 +88,27 @@ describe(meta.route, () => {
|
|||
expect(json.favourited).toBe(false);
|
||||
expect(json.favourites_count).toBe(0);
|
||||
});
|
||||
|
||||
test("post should not be favourited when fetched", async () => {
|
||||
const response = await sendTestRequest(
|
||||
new Request(
|
||||
new URL(
|
||||
`/api/v1/statuses/${timeline[1].id}`,
|
||||
config.http.base_url,
|
||||
),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
const json = (await response.json()) as APIStatus;
|
||||
|
||||
expect(json.favourited).toBe(false);
|
||||
expect(json.favourites_count).toBe(0);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue