|
@@ -1,33 +1,33 @@
|
|
|
import { SPoint } from "../../src";
|
|
|
|
|
|
test("构造函数", () => {
|
|
|
- expect(new SPoint().toJson()).toBe("{\"x\":0,\"y\":0}");
|
|
|
- expect(new SPoint(10, 10).toJson()).toBe("{\"x\":10,\"y\":10}");
|
|
|
+ expect(JSON.stringify(new SPoint())).toBe('{"x":0,"y":0}');
|
|
|
+ expect(JSON.stringify(new SPoint(10, 10))).toBe('{"x":10,"y":10}');
|
|
|
});
|
|
|
|
|
|
test("属性修改", () => {
|
|
|
const p = new SPoint();
|
|
|
- expect(p.toJson()).toBe("{\"x\":0,\"y\":0}");
|
|
|
+ expect(JSON.stringify(p)).toBe('{"x":0,"y":0}');
|
|
|
|
|
|
p.y = 10;
|
|
|
- expect(p.toJson()).toBe("{\"x\":0,\"y\":10}");
|
|
|
+ expect(JSON.stringify(p)).toBe('{"x":0,"y":10}');
|
|
|
p.x = -10;
|
|
|
- expect(p.toJson()).toBe("{\"x\":-10,\"y\":10}");
|
|
|
+ expect(JSON.stringify(p)).toBe('{"x":-10,"y":10}');
|
|
|
|
|
|
p.setPoint(-100, -30);
|
|
|
- expect(p.toJson()).toBe("{\"x\":-100,\"y\":-30}");
|
|
|
+ expect(JSON.stringify(p)).toBe('{"x":-100,"y":-30}');
|
|
|
|
|
|
p.setPoint(new SPoint(-5, -12));
|
|
|
- expect(p.toJson()).toBe("{\"x\":-5,\"y\":-12}");
|
|
|
+ expect(JSON.stringify(p)).toBe('{"x":-5,"y":-12}');
|
|
|
});
|
|
|
|
|
|
test("setPoint()", () => {
|
|
|
const p = new SPoint();
|
|
|
p.setPoint(-100, -30);
|
|
|
- expect(p.toJson()).toBe("{\"x\":-100,\"y\":-30}");
|
|
|
+ expect(JSON.stringify(p)).toBe('{"x":-100,"y":-30}');
|
|
|
|
|
|
p.setPoint(new SPoint(-5, -12));
|
|
|
- expect(p.toJson()).toBe("{\"x\":-5,\"y\":-12}");
|
|
|
+ expect(JSON.stringify(p)).toBe('{"x":-5,"y":-12}');
|
|
|
});
|
|
|
|
|
|
test("manhattanLength()", () => {
|