-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.test.js
40 lines (36 loc) · 911 Bytes
/
test2.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
const { dataBelanjaan, listBelanjaan, totalBelanjaan } = require("./index");
const mockBelanjaan = [
{
nama: "Buku",
harga: 10000,
kuantitas: 2,
},
{
nama: "Bimoli",
harga: 49000,
kuantitas: 1,
},
{
nama: "Notepad",
harga: 100000,
kuantitas: 3,
},
{
nama: "Mystery Box",
harga: 5000,
kuantitas: 4,
},
];
describe("Function - totalBelanjaan", () => {
it("should be a function", async () => {
expect(typeof totalBelanjaan).toBe("function");
});
it("should output right things with original data", async () => {
expect(typeof totalBelanjaan(dataBelanjaan)).toBe("number");
expect(totalBelanjaan(dataBelanjaan)).toBe(158000);
});
it("should output right things with mockup data", async () => {
expect(typeof totalBelanjaan(mockBelanjaan)).toBe("number");
expect(totalBelanjaan(mockBelanjaan)).toBe(389000);
});
});