-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.test.js
49 lines (45 loc) · 1.43 KB
/
test1.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
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 - listBelanjaan", () => {
it("should be a function", async () => {
expect(typeof listBelanjaan).toBe("function");
});
it("should output right things with original data", async () => {
expect(Array.isArray(listBelanjaan(dataBelanjaan))).toBe(true);
expect(listBelanjaan(dataBelanjaan).length).toBe(dataBelanjaan.length);
expect(listBelanjaan(dataBelanjaan)[0]).toBe("- Minyak Goreng Delima x 2");
expect(listBelanjaan(dataBelanjaan)[1]).toBe("- Beras Mamos x 1");
expect(listBelanjaan(dataBelanjaan)[2]).toBe(
"- Larutan Cap Kaki Empat x 8"
);
});
it("should output right things with mockup data", async () => {
expect(Array.isArray(listBelanjaan(mockBelanjaan))).toBe(true);
expect(listBelanjaan(mockBelanjaan).length).toBe(mockBelanjaan.length);
expect(listBelanjaan(mockBelanjaan)[0]).toBe("- Buku x 2");
expect(listBelanjaan(mockBelanjaan)[1]).toBe("- Bimoli x 1");
expect(listBelanjaan(mockBelanjaan)[2]).toBe("- Notepad x 3");
expect(listBelanjaan(mockBelanjaan)[3]).toBe("- Mystery Box x 4");
});
});