-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction.test.js
42 lines (34 loc) · 1.14 KB
/
transaction.test.js
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
39
40
41
42
const Transaction = require("./transaction");
describe("Transaction", () => {
beforeAll(() => {
jest.useFakeTimers();
jest.setSystemTime(new Date("2022-06-20"));
});
afterAll(() => {
jest.useRealTimers();
});
beforeEach(() => {
creditTransaction = new Transaction({ credit: 500, balance: 1000 });
debitTransaction = new Transaction({ debit: 500, balance: 1000 });
});
describe("getDate", () => {
it("should return the date formatted as a string", () => {
expect(creditTransaction.getDate()).toEqual("20/06/2022");
});
});
describe("getCredit", () => {
it("should return the credit amount formatted as a float to 2 decimals", () => {
expect(creditTransaction.getCredit()).toEqual("500.00");
});
});
describe("getDebit()", () => {
it("should return the debt amount formatted as a float to 2 decimals", () => {
expect(debitTransaction.getDebit()).toEqual("500.00");
});
});
describe("getBalance()", () => {
it("should return the balance amount formatted as a float to 2 decimals", () => {
expect(debitTransaction.getBalance()).toEqual("1000.00");
});
});
});