Skip to content

Commit

Permalink
chore: add GET /api/me/votes test (denoland#562)
Browse files Browse the repository at this point in the history
Towards denoland#524
  • Loading branch information
iuioiua authored Sep 10, 2023
1 parent fccb7b3 commit 1f42033
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions e2e_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
createItem,
createNotification,
createUser,
createVote,
ifUserHasNotifications,
type Item,
kv,
Expand Down Expand Up @@ -833,3 +834,29 @@ Deno.test("[e2e] POST /api/comments", async (test) => {
assertObjectMatch(comments[0], comment);
});
});

Deno.test("[e2e] GET /api/me/votes", async () => {
const user = genNewUser();
await createUser(user);
const item1 = genNewItem();
const item2 = genNewItem();
await createItem(item1);
await createItem(item2);
await createVote({
userLogin: user.login,
itemId: item1.id,
createdAt: new Date(),
});
await createVote({
userLogin: user.login,
itemId: item2.id,
createdAt: new Date(),
});
const resp = await handler(
new Request("http://localhost/api/me/votes", {
headers: { cookie: "site-session=" + user.sessionId },
}),
);
const body = await resp.json();
assertArrayIncludes(body, [{ ...item1, score: 1 }, { ...item2, score: 1 }]);
});

0 comments on commit 1f42033

Please sign in to comment.