-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.test.js
More file actions
38 lines (34 loc) · 1.38 KB
/
Copy pathTransaction.test.js
File metadata and controls
38 lines (34 loc) · 1.38 KB
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
const Transaction = require("./Transaction");
const originalDate = Date;
describe('Transaction', () => {
it("creates a transaction object that has a date" , () => {
global.Date = class extends Date {
constructor() {
super('1993-09-22');
}
};
const transaction = new Transaction("deposit", 1000, 4000);
expect(transaction.date).toStrictEqual(`22/09/1993`);
global.Date = originalDate;
})
it("returns the deposit transaction in the required format date || credit || debit || balance", () => {
global.Date = class extends Date {
constructor() {
super('1993-09-22');
}
};
const transaction = new Transaction("deposit", 1000, 4000);
expect(transaction.format()).toStrictEqual(`22/09/1993 || 1000.00 || || 4000.00`);
global.Date = originalDate;
})
it("returns the withdraw transaction in the required format date || credit || debit || balance", () => {
global.Date = class extends Date {
constructor() {
super('2000-01-01');
}
};
const transaction = new Transaction("withdrawal", 666.6, 333.4);
expect(transaction.format()).toStrictEqual(`01/01/2000 || || 666.60 || 333.40`);
global.Date = originalDate;
})
})