-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathiterationMethods.test.js
72 lines (65 loc) · 1.9 KB
/
iterationMethods.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const {
filterIncomeTransactions,
filterExpenseTransactions,
calculateTotalIncome,
calculateTotalExpenses,
calculateNetTotal,
filterSignificantTransactions,
} = require("./iterationMethods.js");
const transactions = [
["income", 1000],
["income", 1500],
["expense", 500],
["expense", 300],
["income", 700],
];
describe("Financial Transaction Analysis", () => {
describe("Transaction Analysis", () => {
describe("filterIncomeTransactions", () => {
it("should filter only income transactions", () => {
expect(filterIncomeTransactions(transactions)).toEqual([
["income", 1000],
["income", 1500],
["income", 700],
]);
});
});
describe("filterExpenseTransactions", () => {
it("should filter only expense transactions", () => {
expect(filterExpenseTransactions(transactions)).toEqual([
["expense", 500],
["expense", 300],
]);
});
});
});
describe("Financial Summary", () => {
describe("calculateTotalIncome", () => {
it("should calculate the total income", () => {
expect(calculateTotalIncome(transactions)).toBe(3200);
});
});
describe("calculateTotalExpenses", () => {
it("should calculate the total expenses", () => {
expect(calculateTotalExpenses(transactions)).toBe(800);
});
});
});
describe("Net Analysis", () => {
describe("calculateNetTotal", () => {
it("should calculate the net total", () => {
expect(calculateNetTotal(transactions)).toBe(2400);
});
});
describe("filterSignificantTransactions", () => {
it("should filter transactions above or equal to $500", () => {
expect(filterSignificantTransactions(transactions)).toEqual([
["income", 1000],
["income", 1500],
["expense", 500],
["income", 700],
]);
});
});
});
});