-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
likes.test.ts
38 lines (29 loc) · 1.04 KB
/
likes.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { describe, expect, it, beforeEach } from "vitest";
import {
seedDatabase,
getTransactionsForUserContacts,
getAllUsers,
getTransactionsByUserId,
createLike,
getLikesByTransactionId,
} from "../../backend/database";
import { User, Transaction } from "../../src/models";
describe("Transactions", () => {
beforeEach(() => {
seedDatabase();
});
it("should like a transaction for a contact", () => {
const user: User = getAllUsers()[0];
const transactions: Transaction[] = getTransactionsForUserContacts(user.id);
const like = createLike(user.id, transactions[0].id);
expect(like.transactionId).toBe(transactions[0].id);
});
it("should get a list of likes for a transaction", () => {
const user: User = getAllUsers()[0];
const transactions: Transaction[] = getTransactionsByUserId(user.id);
const transaction = transactions[0];
createLike(user.id, transaction.id);
const likes = getLikesByTransactionId(transaction.id);
expect(likes[0].transactionId).toBe(transaction.id);
});
});