1- import { getCrossPointOfLine , isInSegment } from '../../src/algorithm/edge' ;
1+ import { getCrossPointOfLine , isInSegment } from '../../src/algorithm/edge'
22
33describe ( 'algorithm/edge' , ( ) => {
44 // one intersection
@@ -12,7 +12,7 @@ describe('algorithm/edge', () => {
1212 x : 10 ,
1313 y : 10 ,
1414 } ,
15- ] ;
15+ ]
1616 const line2 = [
1717 {
1818 x : 10 ,
@@ -22,11 +22,11 @@ describe('algorithm/edge', () => {
2222 x : 0 ,
2323 y : 10 ,
2424 } ,
25- ] ;
25+ ]
2626 expect (
2727 getCrossPointOfLine ( line1 [ 0 ] , line1 [ 1 ] , line2 [ 0 ] , line2 [ 1 ] ) ,
28- ) . toBeTruthy ( ) ;
29- } ) ;
28+ ) . toBeTruthy ( )
29+ } )
3030 // multiple intersection
3131 test ( 'multiple intersection' , ( ) => {
3232 const line1 = [
@@ -38,7 +38,7 @@ describe('algorithm/edge', () => {
3838 x : 10 ,
3939 y : 10 ,
4040 } ,
41- ] ;
41+ ]
4242 const line2 = [
4343 {
4444 x : 0 ,
@@ -48,11 +48,11 @@ describe('algorithm/edge', () => {
4848 x : 10 ,
4949 y : 10 ,
5050 } ,
51- ] ;
51+ ]
5252 expect (
5353 getCrossPointOfLine ( line1 [ 0 ] , line1 [ 1 ] , line2 [ 0 ] , line2 [ 1 ] ) ,
54- ) . toBeFalsy ( ) ;
55- } ) ;
54+ ) . toBeFalsy ( )
55+ } )
5656 // no intersection
5757 test ( 'intersection' , ( ) => {
5858 const line1 = [
@@ -64,7 +64,7 @@ describe('algorithm/edge', () => {
6464 x : 10 ,
6565 y : 10 ,
6666 } ,
67- ] ;
67+ ]
6868 const line2 = [
6969 {
7070 x : 10 ,
@@ -74,18 +74,18 @@ describe('algorithm/edge', () => {
7474 x : 20 ,
7575 y : 10 ,
7676 } ,
77- ] ;
77+ ]
7878 expect (
7979 getCrossPointOfLine ( line1 [ 0 ] , line1 [ 1 ] , line2 [ 0 ] , line2 [ 1 ] ) ,
80- ) . toBeFalsy ( ) ;
81- } ) ;
80+ ) . toBeFalsy ( )
81+ } )
8282
8383 test ( 'in segment' , ( ) => {
8484 const point = {
8585 x : 0 ,
8686 y : 0 ,
87- } ;
88- const line = [
87+ }
88+ const line1 = [
8989 {
9090 x : - 10 ,
9191 y : - 10 ,
@@ -94,15 +94,28 @@ describe('algorithm/edge', () => {
9494 x : 10 ,
9595 y : 10 ,
9696 } ,
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+ } )
100113 // not in segment
101114 test ( 'not in segment' , ( ) => {
102115 const point = {
103116 x : 10 ,
104117 y : 0 ,
105- } ;
118+ }
106119 const line = [
107120 {
108121 x : - 10 ,
@@ -112,7 +125,7 @@ describe('algorithm/edge', () => {
112125 x : 10 ,
113126 y : 10 ,
114127 } ,
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