@@ -2,7 +2,6 @@ import React from 'react'
2
2
import { mock , instance } from 'ts-mockito'
3
3
4
4
import { render } from 'uiSrc/utils/test-utils'
5
- import * as Services from 'uiSrc/services'
6
5
import VirtualTree , { Props } from './VirtualTree'
7
6
8
7
const mockedProps = mock < Props > ( )
@@ -16,37 +15,36 @@ const mockedItems = [
16
15
} ,
17
16
]
18
17
19
- const mockTreeItem = {
20
- children : [ {
18
+ export const mockVirtualTreeResult = [
19
+ {
20
+ children : [ {
21
+ children : [ ] ,
22
+ fullName : 'car:110:' ,
23
+ id : '0.snc1rc3zwgo' ,
24
+ keyApproximate : 0.01 ,
25
+ keyCount : 1 ,
26
+ name : '110' ,
27
+ } ] ,
28
+ fullName : 'car:' ,
29
+ id : '0.sz1ie1koqi8' ,
30
+ keyApproximate : 47.18 ,
31
+ keyCount : 4718 ,
32
+ name : 'car' ,
33
+ } ,
34
+ {
21
35
children : [ ] ,
22
- fullName : 'car:110: ' ,
23
- id : '0.snc1rc3zwgo ' ,
36
+ fullName : 'test ' ,
37
+ id : '0.snc1rc3zwg1o ' ,
24
38
keyApproximate : 0.01 ,
25
39
keyCount : 1 ,
26
- name : '110' ,
27
- } ] ,
28
- fullName : 'car:' ,
29
- id : '0.sz1ie1koqi8' ,
30
- keyApproximate : 47.18 ,
31
- keyCount : 4718 ,
32
- name : 'car' ,
33
- }
34
-
35
- const mockTreeItem2 = {
36
- children : [ ] ,
37
- fullName : 'test' ,
38
- id : '0.snc1rc3zwg1o' ,
39
- keyApproximate : 0.01 ,
40
- keyCount : 1 ,
41
- name : 'test' ,
42
- }
43
-
44
- export const mockVirtualTreeResult = [ mockTreeItem , mockTreeItem2 ]
40
+ name : 'test' ,
41
+ }
42
+ ]
45
43
46
44
jest . mock ( 'uiSrc/services' , ( ) => ( {
47
45
__esModule : true ,
48
46
...jest . requireActual ( 'uiSrc/services' ) ,
49
- useDisposableWebworker : jest . fn ( ) . mockReturnValue ( { result : mockVirtualTreeResult , run : jest . fn ( ) } )
47
+ useDisposableWebworker : ( ) => ( { result : mockVirtualTreeResult , run : jest . fn ( ) } )
50
48
} ) )
51
49
52
50
describe ( 'VirtualTree' , ( ) => {
@@ -68,9 +66,6 @@ describe('VirtualTree', () => {
68
66
} )
69
67
70
68
it ( 'should render items' , async ( ) => {
71
- jest . spyOn ( Services , 'useDisposableWebworker' )
72
- . mockReturnValueOnce ( { result : [ mockTreeItem , mockTreeItem2 ] , run : jest . fn ( ) } )
73
-
74
69
const mockFn = jest . fn ( )
75
70
const { queryByTestId } = render (
76
71
< VirtualTree
@@ -83,24 +78,6 @@ describe('VirtualTree', () => {
83
78
expect ( queryByTestId ( 'node-item_test' ) ) . toBeInTheDocument ( )
84
79
} )
85
80
86
- it ( 'should call onStatusOpen if only one folder is exist' , ( ) => {
87
- jest . spyOn ( Services , 'useDisposableWebworker' )
88
- . mockReturnValueOnce ( { result : [ mockTreeItem ] , run : jest . fn ( ) } )
89
-
90
- const mockFn = jest . fn ( )
91
- const mockOnStatusOpen = jest . fn ( )
92
-
93
- render (
94
- < VirtualTree
95
- { ...instance ( mockedProps ) }
96
- onStatusOpen = { mockOnStatusOpen }
97
- setConstructingTree = { mockFn }
98
- />
99
- )
100
-
101
- expect ( mockOnStatusOpen ) . toBeCalledWith ( 'car:' , true )
102
- } )
103
-
104
81
it ( 'should not call onStatusOpen if more than one folder is exist' , ( ) => {
105
82
const mockFn = jest . fn ( )
106
83
const mockOnStatusOpen = jest . fn ( )
0 commit comments