1
- import { getCrossPointOfLine , isInSegment } from '../../src/algorithm/edge' ;
1
+ import { getCrossPointOfLine , isInSegment } from '../../src/algorithm/edge'
2
2
3
3
describe ( 'algorithm/edge' , ( ) => {
4
4
// one intersection
@@ -12,7 +12,7 @@ describe('algorithm/edge', () => {
12
12
x : 10 ,
13
13
y : 10 ,
14
14
} ,
15
- ] ;
15
+ ]
16
16
const line2 = [
17
17
{
18
18
x : 10 ,
@@ -22,11 +22,11 @@ describe('algorithm/edge', () => {
22
22
x : 0 ,
23
23
y : 10 ,
24
24
} ,
25
- ] ;
25
+ ]
26
26
expect (
27
27
getCrossPointOfLine ( line1 [ 0 ] , line1 [ 1 ] , line2 [ 0 ] , line2 [ 1 ] ) ,
28
- ) . toBeTruthy ( ) ;
29
- } ) ;
28
+ ) . toBeTruthy ( )
29
+ } )
30
30
// multiple intersection
31
31
test ( 'multiple intersection' , ( ) => {
32
32
const line1 = [
@@ -38,7 +38,7 @@ describe('algorithm/edge', () => {
38
38
x : 10 ,
39
39
y : 10 ,
40
40
} ,
41
- ] ;
41
+ ]
42
42
const line2 = [
43
43
{
44
44
x : 0 ,
@@ -48,11 +48,11 @@ describe('algorithm/edge', () => {
48
48
x : 10 ,
49
49
y : 10 ,
50
50
} ,
51
- ] ;
51
+ ]
52
52
expect (
53
53
getCrossPointOfLine ( line1 [ 0 ] , line1 [ 1 ] , line2 [ 0 ] , line2 [ 1 ] ) ,
54
- ) . toBeFalsy ( ) ;
55
- } ) ;
54
+ ) . toBeFalsy ( )
55
+ } )
56
56
// no intersection
57
57
test ( 'intersection' , ( ) => {
58
58
const line1 = [
@@ -64,7 +64,7 @@ describe('algorithm/edge', () => {
64
64
x : 10 ,
65
65
y : 10 ,
66
66
} ,
67
- ] ;
67
+ ]
68
68
const line2 = [
69
69
{
70
70
x : 10 ,
@@ -74,18 +74,18 @@ describe('algorithm/edge', () => {
74
74
x : 20 ,
75
75
y : 10 ,
76
76
} ,
77
- ] ;
77
+ ]
78
78
expect (
79
79
getCrossPointOfLine ( line1 [ 0 ] , line1 [ 1 ] , line2 [ 0 ] , line2 [ 1 ] ) ,
80
- ) . toBeFalsy ( ) ;
81
- } ) ;
80
+ ) . toBeFalsy ( )
81
+ } )
82
82
83
83
test ( 'in segment' , ( ) => {
84
84
const point = {
85
85
x : 0 ,
86
86
y : 0 ,
87
- } ;
88
- const line = [
87
+ }
88
+ const line1 = [
89
89
{
90
90
x : - 10 ,
91
91
y : - 10 ,
@@ -94,15 +94,28 @@ describe('algorithm/edge', () => {
94
94
x : 10 ,
95
95
y : 10 ,
96
96
} ,
97
- ] ;
98
- expect ( isInSegment ( point , line [ 0 ] , line [ 1 ] ) ) . toBeTruthy ( ) ;
99
- } ) ;
97
+ ]
98
+ const line2 = [
99
+ {
100
+ x : - 10 ,
101
+ y : 10 ,
102
+ } ,
103
+ {
104
+ x : 10 ,
105
+ y : - 10 ,
106
+ } ,
107
+ ]
108
+ expect ( isInSegment ( point , line1 [ 0 ] , line2 [ 1 ] ) ) . toBeTruthy ( )
109
+ expect ( isInSegment ( point , line1 [ 1 ] , line2 [ 0 ] ) ) . toBeTruthy ( )
110
+ expect ( isInSegment ( point , line2 [ 0 ] , line1 [ 1 ] ) ) . toBeTruthy ( )
111
+ expect ( isInSegment ( point , line2 [ 1 ] , line1 [ 0 ] ) ) . toBeTruthy ( )
112
+ } )
100
113
// not in segment
101
114
test ( 'not in segment' , ( ) => {
102
115
const point = {
103
116
x : 10 ,
104
117
y : 0 ,
105
- } ;
118
+ }
106
119
const line = [
107
120
{
108
121
x : - 10 ,
@@ -112,7 +125,7 @@ describe('algorithm/edge', () => {
112
125
x : 10 ,
113
126
y : 10 ,
114
127
} ,
115
- ] ;
116
- expect ( isInSegment ( point , line [ 0 ] , line [ 1 ] ) ) . toBeFalsy ( ) ;
117
- } ) ;
118
- } ) ;
128
+ ]
129
+ expect ( isInSegment ( point , line [ 0 ] , line [ 1 ] ) ) . toBeFalsy ( )
130
+ } )
131
+ } )
0 commit comments