Skip to content

Commit 21334dd

Browse files
committed
feat: update tests
1 parent 3fad772 commit 21334dd

File tree

5 files changed

+65
-4
lines changed

5 files changed

+65
-4
lines changed

tests/bookmarks/delete-bookmark.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ beforeAll(async () => {
77
await prisma.bookmark.deleteMany({});
88
});
99

10-
test('DELETE /bookmarks', async (ctx: OasisTestContext) => {
10+
test('DELETE /bookmarks/{id}', async (ctx: OasisTestContext) => {
1111
const { user } = getSetupData();
1212
const { http } = await new IntegrationHarness(ctx).init();
1313

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { prisma } from '@/lib/db';
2+
import { IntegrationHarness } from '@/tests/utils/integration';
3+
import { OasisTestContext, getSetupData } from '@/tests/utils/setup';
4+
import { Bookmark } from '@prisma/client';
5+
import { afterAll, beforeAll, expect, test } from 'vitest';
6+
7+
beforeAll(async () => {
8+
await prisma.bookmark.deleteMany({});
9+
});
10+
11+
test('PATCH /bookmarks/{id}', async (ctx: OasisTestContext) => {
12+
const { user } = getSetupData();
13+
const { http } = await new IntegrationHarness(ctx).init();
14+
15+
const initialBookmark = await prisma.bookmark.create({
16+
data: {
17+
userId: user.id,
18+
url: 'https://www.example.com/',
19+
title: 'Example Title',
20+
description: 'Example Description',
21+
isFavorite: true,
22+
visits: 0,
23+
},
24+
});
25+
26+
const {
27+
status,
28+
data: { success, message },
29+
} = await http.patch<Bookmark>({
30+
path: `/bookmarks/${initialBookmark.id}`,
31+
body: {
32+
description: 'UPDATE AGAIN',
33+
visits: 50,
34+
},
35+
});
36+
37+
expect(status).toBe(200);
38+
expect(success).toBe(true);
39+
expect(message).toBe('Bookmark updated successfully.');
40+
41+
const updatedBookmark = await prisma.bookmark.findUnique({
42+
where: {
43+
id: initialBookmark.id,
44+
},
45+
});
46+
47+
expect(updatedBookmark).toEqual(
48+
expect.objectContaining({
49+
userId: user.id,
50+
url: 'https://www.example.com/',
51+
title: 'Example Title',
52+
description: 'UPDATE AGAIN',
53+
isFavorite: true,
54+
visits: 50,
55+
}),
56+
);
57+
});
58+
59+
afterAll(async () => {
60+
await prisma.bookmark.deleteMany({});
61+
});

tests/bookmarks/show-bookmark.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ beforeAll(async () => {
88
await prisma.bookmark.deleteMany({});
99
});
1010

11-
test('GET /bookmarks/{ID}', async (ctx: OasisTestContext) => {
11+
test('GET /bookmarks/{id}', async (ctx: OasisTestContext) => {
1212
const { user } = getSetupData();
1313
const { http } = await new IntegrationHarness(ctx).init();
1414

tests/bookmarks/update-bookmark.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ beforeAll(async () => {
88
await prisma.bookmark.deleteMany({});
99
});
1010

11-
test('UPDATE /bookmarks', async (ctx: OasisTestContext) => {
11+
test('UPDATE /bookmarks/{id}', async (ctx: OasisTestContext) => {
1212
const { user } = getSetupData();
1313
const { http } = await new IntegrationHarness(ctx).init();
1414

tests/tokens/delete-token.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { OasisTestContext, getSetupData } from '@/tests/utils/setup';
55
import { randomBytes } from 'crypto';
66
import { expect, test } from 'vitest';
77

8-
test('DELETE /tokens', async (ctx: OasisTestContext) => {
8+
test('DELETE /tokens/{id}', async (ctx: OasisTestContext) => {
99
const { user } = getSetupData();
1010
const { http } = await new IntegrationHarness(ctx).init();
1111

0 commit comments

Comments
 (0)