@@ -7,36 +7,17 @@ import { useDeleteConversation, usePatchConversation } from '../use_conversation
7
7
import { renderHook , act } from '@testing-library/react-hooks' ;
8
8
import { useCore } from '../../contexts/core_context' ;
9
9
import { HttpHandler } from '../../../../../src/core/public' ;
10
- import { DataSourceServiceMock } from '../../services/data_source_service.mock' ;
11
- import { httpServiceMock } from '../../../../../src/core/public/mocks' ;
12
- jest . mock ( '../../contexts/core_context' ) ;
13
-
14
- const setup = ( ) => {
15
- const useCoreMocked = useCore as jest . MockedFunction < typeof useCore > ;
16
- const mockedDataSource = new DataSourceServiceMock ( ) ;
17
- const mockedHttp = httpServiceMock . createStartContract ( ) ;
18
- mockedHttp . delete = jest . fn ( ( ) => Promise . resolve ( ) ) ;
19
- mockedHttp . put = jest . fn ( ( ) => Promise . resolve ( ) ) ;
20
-
21
- useCoreMocked . mockReturnValue ( {
22
- services : {
23
- dataSource : mockedDataSource ,
24
- http : mockedHttp ,
25
- } ,
26
- } ) ;
27
10
28
- return useCoreMocked ;
29
- } ;
11
+ jest . mock ( '../../contexts/core_context' ) ;
12
+ const useCoreMocked = useCore as jest . MockedFunction < typeof useCore > ;
30
13
31
14
describe ( 'useDeleteConversation' , ( ) => {
32
- const useCoreMocked = setup ( ) ;
33
15
it ( 'should call delete with path and signal' , async ( ) => {
34
16
const { result } = renderHook ( ( ) => useDeleteConversation ( ) ) ;
35
17
36
18
await act ( async ( ) => {
37
19
await result . current . deleteConversation ( 'foo' ) ;
38
20
} ) ;
39
-
40
21
expect ( useCoreMocked . mock . results [ 0 ] . value . services . http . delete ) . toHaveBeenCalledWith (
41
22
'/api/assistant/conversation/foo' ,
42
23
expect . objectContaining ( {
@@ -115,8 +96,6 @@ describe('useDeleteConversation', () => {
115
96
} ) ;
116
97
117
98
describe ( 'usePatchConversation' , ( ) => {
118
- const useCoreMocked = setup ( ) ;
119
-
120
99
it ( 'should call put with path, query and signal' , async ( ) => {
121
100
const { result } = renderHook ( ( ) => usePatchConversation ( ) ) ;
122
101
0 commit comments