-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathspreadsheet.test.js
More file actions
51 lines (44 loc) · 1.28 KB
/
spreadsheet.test.js
File metadata and controls
51 lines (44 loc) · 1.28 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
39
40
41
42
43
44
45
46
47
48
49
50
51
const Spreadsheet = require("./spreadsheet.js");
describe("Spreadsheet", () => {
let s;
beforeEach(() => {
s = new Spreadsheet();
});
test("can write basic values successfully", () => {
s.put("A1", "1");
s.put("A2", "2");
s.put("A3", "3");
expect(s.cells).toEqual({ A1: "1", A2: "2", A3: "3" });
});
test("can write equations successfully", () => {
s.put("B1", "=A1+A2");
s.put("B2", "=B1+2");
s.put("B3", "=B1+B2+5");
expect(s.cells).toEqual({
B1: "=A1+A2",
B2: "=B1+2",
B3: "=B1+B2+5",
});
});
test("fetches correct value for numbers", () => {
s.put("A1", "1");
expect(s.get("A1")).toBe(1);
});
test("fetches correct value for equations", () => {
s.put("A1", "1");
s.put("A2", "2");
s.put("B1", "=A1+A2");
expect(s.get("B1")).toBe(3);
});
test("will overwrite cache with updates values", () => {
s.put("A1", "1");
s.put("A2", "2");
s.put("A3", "3");
s.put("B1", "=A1+A2");
s.put("B2", "=B1+2");
s.put("B3", "=B1+B2+5");
expect(s.get("B3")).toEqual(13);
s.put("B2", "=4+5+A1");
expect(s.get("B3")).toBe(18);
});
});