@@ -9,60 +9,77 @@ const parsed = convert(data, { noContour: true }).flatten[0];
9
9
describe ( 'conrec basic test' , ( ) => {
10
10
it ( 'no result because level too far' , ( ) => {
11
11
const conrec = new Conrec ( parsed . minMax . z ) ;
12
- const basic = conrec . drawContour ( {
12
+ const { contours , timeout } = conrec . drawContour ( {
13
13
contourDrawer : 'basic' ,
14
14
levels : [ - 1000000000 , 1000000000 ] ,
15
15
timeout : 10000 ,
16
16
} ) ;
17
-
18
- expect ( basic ) . toStrictEqual ( [
17
+ expect ( timeout ) . toBeFalsy ( ) ;
18
+ expect ( contours ) . toStrictEqual ( [
19
19
{ lines : [ ] , zValue : - 1000000000 } ,
20
20
{ lines : [ ] , zValue : 1000000000 } ,
21
21
] ) ;
22
22
} ) ;
23
23
24
24
it ( '2 specified levels' , ( ) => {
25
25
const conrec = new Conrec ( parsed . minMax . z ) ;
26
- const basic = conrec . drawContour ( {
26
+ const { contours , timeout } = conrec . drawContour ( {
27
27
contourDrawer : 'basic' ,
28
28
levels : [ - 100000 , 100000 ] ,
29
29
timeout : 10000 ,
30
30
} ) ;
31
-
32
- expect ( basic ) . toHaveLength ( 2 ) ;
33
- expect ( basic [ 0 ] . lines ) . toHaveLength ( 36864 ) ;
34
- expect ( basic [ 1 ] . lines ) . toHaveLength ( 119720 ) ;
31
+ expect ( timeout ) . toBeFalsy ( ) ;
32
+ expect ( contours ) . toHaveLength ( 2 ) ;
33
+ expect ( contours [ 0 ] . lines ) . toHaveLength ( 36864 ) ;
34
+ expect ( contours [ 1 ] . lines ) . toHaveLength ( 119720 ) ;
35
35
} ) ;
36
36
37
37
it ( 'auto select levels' , ( ) => {
38
38
const conrec = new Conrec ( parsed . minMax . z ) ;
39
- const basic = conrec . drawContour ( {
39
+ const { contours , timeout } = conrec . drawContour ( {
40
40
contourDrawer : 'basic' ,
41
41
nbLevels : 10 ,
42
42
timeout : 10000 ,
43
43
} ) ;
44
44
45
- expect ( basic ) . toHaveLength ( 10 ) ;
46
- expect ( basic [ 0 ] . lines ) . toHaveLength ( 0 ) ;
47
- expect ( basic [ 1 ] . lines ) . toHaveLength ( 4984 ) ;
48
- expect ( basic [ 8 ] . lines ) . toHaveLength ( 32 ) ;
49
- expect ( basic [ 8 ] . lines ) . toMatchSnapshot ( ) ;
50
- expect ( basic [ 9 ] . lines ) . toHaveLength ( 0 ) ;
45
+ expect ( timeout ) . toBeFalsy ( ) ;
46
+ expect ( contours ) . toHaveLength ( 10 ) ;
47
+ expect ( contours [ 0 ] . lines ) . toHaveLength ( 0 ) ;
48
+ expect ( contours [ 1 ] . lines ) . toHaveLength ( 4984 ) ;
49
+ expect ( contours [ 8 ] . lines ) . toHaveLength ( 32 ) ;
50
+ expect ( contours [ 8 ] . lines ) . toMatchSnapshot ( ) ;
51
+ expect ( contours [ 9 ] . lines ) . toHaveLength ( 0 ) ;
51
52
} ) ;
52
53
53
54
it ( 'auto select levels with swapAxes' , ( ) => {
54
55
const conrec = new Conrec ( parsed . minMax . z , { swapAxes : true } ) ;
55
- const basic = conrec . drawContour ( {
56
+ const { contours , timeout } = conrec . drawContour ( {
56
57
contourDrawer : 'basic' ,
57
58
nbLevels : 10 ,
58
59
timeout : 10000 ,
59
60
} ) ;
60
61
61
- expect ( basic ) . toHaveLength ( 10 ) ;
62
- expect ( basic [ 0 ] . lines ) . toHaveLength ( 0 ) ;
63
- expect ( basic [ 1 ] . lines ) . toHaveLength ( 4984 ) ;
64
- expect ( basic [ 8 ] . lines ) . toHaveLength ( 32 ) ;
65
- expect ( basic [ 8 ] . lines ) . toMatchSnapshot ( ) ;
66
- expect ( basic [ 9 ] . lines ) . toHaveLength ( 0 ) ;
62
+ expect ( timeout ) . toBeFalsy ( ) ;
63
+ expect ( contours ) . toHaveLength ( 10 ) ;
64
+ expect ( contours [ 0 ] . lines ) . toHaveLength ( 0 ) ;
65
+ expect ( contours [ 1 ] . lines ) . toHaveLength ( 4984 ) ;
66
+ expect ( contours [ 8 ] . lines ) . toHaveLength ( 32 ) ;
67
+ expect ( contours [ 8 ] . lines ) . toMatchSnapshot ( ) ;
68
+ expect ( contours [ 9 ] . lines ) . toHaveLength ( 0 ) ;
69
+ } ) ;
70
+
71
+ it ( 'return available contours within 100ms' , ( ) => {
72
+ const conrec = new Conrec ( parsed . minMax . z ) ;
73
+ const { contours, timeout } = conrec . drawContour ( {
74
+ contourDrawer : 'basic' ,
75
+ nbLevels : 10 ,
76
+ timeout : 100 ,
77
+ } ) ;
78
+ expect ( timeout ) . toBeTruthy ( ) ;
79
+ expect ( contours ) . toHaveLength ( 10 ) ;
80
+ expect ( contours [ 0 ] . lines ) . toHaveLength ( 0 ) ;
81
+ expect ( contours [ 1 ] . lines . length ) . toBeLessThan ( 2000 ) ;
82
+ expect ( contours [ 8 ] . lines ) . toHaveLength ( 0 ) ;
83
+ expect ( contours [ 9 ] . lines ) . toHaveLength ( 0 ) ;
67
84
} ) ;
68
85
} ) ;
0 commit comments