Skip to content

Commit 37ec5d7

Browse files
Expectations added.
1 parent 51d4923 commit 37ec5d7

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

graph.test.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ test("Inserting functions", function () {
117117

118118
test("Drawing", function () {
119119
var myGraph = new graph();
120+
var lineTo = jest.fn();
121+
myGraph.ctx.lineTo = lineTo;
120122
myGraph.reRoll(Math.PI * -0.5, 0);
121123
myGraph.zee = -2500;
122124
myGraph.colours = ["red"];
@@ -132,19 +134,15 @@ test("Drawing", function () {
132134
myGraph.function_switches["voyager"] = false;
133135
myGraph.canvas.onmousemove({buttons: 2, movementX: 2, movementY: -1});
134136
myGraph.canvas.onmousemove({buttons: 3, movementX: 2, movementY: -1});
137+
expect(lineTo).toHaveBeenCalled();
138+
lineTo = jest.fn();
139+
myGraph.ctx.lineTo = lineTo;
135140
delete myGraph.ctx;
136141
myGraph.draw();
137142
Object.defineProperty(myGraph.canvas, "offsetWidth", {value: 100, writable: false});
138143
Object.defineProperty(myGraph.canvas, "offsetHeight", {value: 100, writable: false});
139144
myGraph.draw();
140-
});
141-
142-
test("Drawing in <div>.", function () {
143-
var g = document.getElementById;
144-
buildDiv("graph_id");
145-
var myGraph = new graph("graph_id");
146-
myGraph.draw();
147-
document.getElementById = g;
145+
expect(lineTo).not.toHaveBeenCalled();
148146
});
149147

150148
test("Insert switch panel into <body>.", function () {

0 commit comments

Comments
 (0)