forked from anseki/leader-line
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolygon2PathList-test.html
103 lines (88 loc) · 3.11 KB
/
polygon2PathList-test.html
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.4.1</title>
<link rel="shortcut icon" type="image/png" href="./jasmine-2.4.1/jasmine_favicon.png">
<link rel="stylesheet" href="./jasmine-2.4.1/jasmine.css">
<script src="./jasmine-2.4.1/jasmine.js"></script>
<script src="./jasmine-2.4.1/jasmine-html.js"></script>
<script src="./jasmine-2.4.1/boot.js"></script>
<script src="./polygon2PathList.js"></script>
<script>
(function() {
'use strict';
describe('polygon2PathList', function() {
it('getPointObject', function() {
expect(polygon2PathList([
[10, 100],
[11, 101, true],
[12, 102],
{x: 13, y: 103},
[14, 104],
{x: 15, y: 105},
[16, 106],
[17, 107],
{x: 18, y: 108},
{x: 19, y: 109}
])).toEqual([
[{x: 10, y: 100}, {x: 11, y: 101}],
[{x: 11, y: 101}, {x: 12, y: 102}],
[{x: 12, y: 102}, {x: 13, y: 103}],
[{x: 13, y: 103}, {x: 14, y: 104}],
[{x: 14, y: 104}, {x: 15, y: 105}],
[{x: 15, y: 105}, {x: 16, y: 106}],
[{x: 16, y: 106}, {x: 17, y: 107}],
[{x: 17, y: 107}, {x: 18, y: 108}],
[{x: 18, y: 108}, {x: 19, y: 109}]
]);
expect(polygon2PathList.currentPoint).toEqual({x: 19, y: 109});
});
it('change isAbs', function() {
expect(polygon2PathList([
[10, 100],
[1, 2], // 11, 102
[3, 4], // 14, 106
{x: 5, y: 6}, // 19, 112
[7, 8], // 26, 120
{x: 9, y: 10}, // 35, 130
[16, 106, true], // 16, 106
[17, 107], // 17, 107
{x: 1, y: 2, isAbs: false}, // 18, 109
{x: 3, y: 4} // 21, 113
])).toEqual([
[{x: 10, y: 100}, {x: 11, y: 102}],
[{x: 11, y: 102}, {x: 14, y: 106}],
[{x: 14, y: 106}, {x: 19, y: 112}],
[{x: 19, y: 112}, {x: 26, y: 120}],
[{x: 26, y: 120}, {x: 35, y: 130}],
[{x: 35, y: 130}, {x: 16, y: 106}],
[{x: 16, y: 106}, {x: 17, y: 107}],
[{x: 17, y: 107}, {x: 18, y: 109}],
[{x: 18, y: 109}, {x: 21, y: 113}]
]);
expect(polygon2PathList.currentPoint).toEqual({x: 21, y: 113});
});
it('currentPoint', function() {
expect(polygon2PathList([[10, 100], [1, 2]])).toEqual([
[{x: 10, y: 100}, {x: 11, y: 102}]
]);
expect(polygon2PathList.currentPoint).toEqual({x: 11, y: 102});
expect(polygon2PathList([polygon2PathList.currentPoint, [1, 2], [3, 4]])).toEqual([
[{x: 11, y: 102}, {x: 12, y: 104}],
[{x: 12, y: 104}, {x: 15, y: 108}],
]);
expect(polygon2PathList.currentPoint).toEqual({x: 15, y: 108});
expect(polygon2PathList([polygon2PathList.currentPoint, [1, 2], [3, 4]])).toEqual([
[{x: 15, y: 108}, {x: 16, y: 110}],
[{x: 16, y: 110}, {x: 19, y: 114}],
]);
expect(polygon2PathList.currentPoint).toEqual({x: 19, y: 114});
});
});
})();
</script>
</head>
<body>
</body>
</html>