mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
test(api): 🔥 Clean up old duplicated tests
This commit is contained in:
parent
0ca8000186
commit
245d4844f5
|
|
@ -16,37 +16,6 @@ describe("API Tests", () => {
|
||||||
await deleteUsers();
|
await deleteUsers();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("GET /api/v1/instance", () => {
|
|
||||||
test("should return an APIInstance object", async () => {
|
|
||||||
const response = await sendTestRequest(
|
|
||||||
new Request(
|
|
||||||
wrapRelativeUrl(`${base_url}/api/v1/instance`, base_url),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(response.status).toBe(200);
|
|
||||||
expect(response.headers.get("content-type")).toBe(
|
|
||||||
"application/json",
|
|
||||||
);
|
|
||||||
|
|
||||||
const instance = (await response.json()) as APIInstance;
|
|
||||||
|
|
||||||
expect(instance.uri).toBe(config.http.base_url);
|
|
||||||
expect(instance.title).toBeDefined();
|
|
||||||
expect(instance.description).toBeDefined();
|
|
||||||
expect(instance.email).toBeDefined();
|
|
||||||
expect(instance.version).toBeDefined();
|
|
||||||
expect(instance.urls).toBeDefined();
|
|
||||||
expect(instance.stats).toBeDefined();
|
|
||||||
expect(instance.thumbnail).toBeDefined();
|
|
||||||
expect(instance.languages).toBeDefined();
|
|
||||||
// Not implemented yet
|
|
||||||
// expect(instance.contact_account).toBeDefined();
|
|
||||||
expect(instance.rules).toBeDefined();
|
|
||||||
expect(instance.approval_required).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("GET /api/v1/custom_emojis", () => {
|
describe("GET /api/v1/custom_emojis", () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await db.insert(emoji).values({
|
await db.insert(emoji).values({
|
||||||
|
|
|
||||||
|
|
@ -17,26 +17,6 @@ afterAll(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("API Tests", () => {
|
describe("API Tests", () => {
|
||||||
describe("POST /api/v1/accounts/:id", () => {
|
|
||||||
test("should return a 404 error when trying to fetch a non-existent user", async () => {
|
|
||||||
const response = await sendTestRequest(
|
|
||||||
new Request(
|
|
||||||
wrapRelativeUrl("/api/v1/accounts/999999", base_url),
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${token.accessToken}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(response.status).toBe(404);
|
|
||||||
expect(response.headers.get("content-type")).toBe(
|
|
||||||
"application/json",
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("PATCH /api/v1/accounts/update_credentials", () => {
|
describe("PATCH /api/v1/accounts/update_credentials", () => {
|
||||||
test("should update the authenticated user's display name", async () => {
|
test("should update the authenticated user's display name", async () => {
|
||||||
const response = await sendTestRequest(
|
const response = await sendTestRequest(
|
||||||
|
|
@ -675,43 +655,6 @@ describe("API Tests", () => {
|
||||||
|
|
||||||
expect(Array.isArray(familiarFollowers)).toBe(true);
|
expect(Array.isArray(familiarFollowers)).toBe(true);
|
||||||
expect(familiarFollowers.length).toBe(0);
|
expect(familiarFollowers.length).toBe(0);
|
||||||
/* expect(typeof familiarFollowers[0].id).toBe("string");
|
|
||||||
expect(Array.isArray(familiarFollowers[0].accounts)).toBe(true);
|
|
||||||
expect(familiarFollowers[0].accounts.length).toBeGreaterThanOrEqual(
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
if (familiarFollowers[0].accounts.length === 0) return;
|
|
||||||
expect(familiarFollowers[0].accounts[0].id).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].username).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].acct).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].display_name).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].locked).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].bot).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].discoverable).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].group).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].created_at).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].note).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].url).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].avatar).toBeDefined();
|
|
||||||
expect(
|
|
||||||
familiarFollowers[0].accounts[0].avatar_static
|
|
||||||
).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].header).toBeDefined();
|
|
||||||
expect(
|
|
||||||
familiarFollowers[0].accounts[0].header_static
|
|
||||||
).toBeDefined();
|
|
||||||
expect(
|
|
||||||
familiarFollowers[0].accounts[0].followers_count
|
|
||||||
).toBeDefined();
|
|
||||||
expect(
|
|
||||||
familiarFollowers[0].accounts[0].following_count
|
|
||||||
).toBeDefined();
|
|
||||||
expect(
|
|
||||||
familiarFollowers[0].accounts[0].statuses_count
|
|
||||||
).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].emojis).toBeDefined();
|
|
||||||
expect(familiarFollowers[0].accounts[0].fields).toBeDefined(); */
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -288,34 +288,6 @@ describe("API Tests", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("GET /api/v1/timelines/public", () => {
|
|
||||||
test("should return an array of APIStatus objects that includes the created status", async () => {
|
|
||||||
const response = await sendTestRequest(
|
|
||||||
new Request(
|
|
||||||
wrapRelativeUrl(
|
|
||||||
`${base_url}/api/v1/timelines/public`,
|
|
||||||
base_url,
|
|
||||||
),
|
|
||||||
{
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${token.accessToken}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(response.status).toBe(200);
|
|
||||||
expect(response.headers.get("content-type")).toBe(
|
|
||||||
"application/json",
|
|
||||||
);
|
|
||||||
|
|
||||||
const statuses = (await response.json()) as APIStatus[];
|
|
||||||
|
|
||||||
expect(statuses.some((s) => s.id === status?.id)).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("GET /api/v1/accounts/:id/statuses", () => {
|
describe("GET /api/v1/accounts/:id/statuses", () => {
|
||||||
test("should return the statuses of the specified user", async () => {
|
test("should return the statuses of the specified user", async () => {
|
||||||
const response = await sendTestRequest(
|
const response = await sendTestRequest(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue