-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpoint.spec.js
44 lines (34 loc) · 1.19 KB
/
point.spec.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
// Run this module via jasmine-node (installable by npm)
// https://github.com/mhevery/jasmine-node
var Point = require("./point.js").Point;
describe("add", function() {
it("adds points", function() {
var p = new Point();
p._ = new Point(1, 2) + new Point(3, 4) + new Point(5, 6);
expect(p.equals(new Point(9, 12))).toBe(true);
// Strings work, too
p._ = new Point("a", "b") + new Point("c", "d") + new Point("e", "f");
expect(p.equals(new Point("ace", "bdf"))).toBe(true);
});
});
describe("multiply", function() {
it("multiplies points", function() {
var p = new Point();
p._ = new Point(1, 2) * new Point(3, 4) * new Point(5, 6);
expect(p.equals(new Point(15, 48))).toBe(true);
});
});
describe("subtract", function() {
it("subtracts points", function() {
var p = new Point();
p._ = new Point(9, 8) - new Point(3, 4);
expect(p.equals(new Point(6, 4))).toBe(true);
});
});
describe("divide", function() {
it("divides points", function() {
var p = new Point();
p._ = new Point(9, 8) / new Point(3, 4);
expect(p.equals(new Point(3, 2))).toBe(true);
});
});