1
1
import { MantineProvider } from '@mantine/core' ;
2
2
import { fireEvent , render , screen } from '@testing-library/react' ;
3
+ import { PropsWithChildren } from 'react' ;
3
4
import { describe , expect , it , vi } from 'vitest' ;
5
+ import { ProfileContext } from 'src/hooks' ;
4
6
import { InAppDocsProvider , useDocsContext } from './InAppDocsProvider' ;
5
7
6
8
vi . mock ( 'react-router-dom' , ( ) => ( {
@@ -17,6 +19,11 @@ vi.mock('@tanstack/react-query', () => ({
17
19
} ) ) ,
18
20
} ) ) ;
19
21
22
+ const ProfileProvider = ( { children } : PropsWithChildren ) => (
23
+ < ProfileContext . Provider value = { { id :
'' , name :
'Admin' , email :
'[email protected] ' , isAdmin :
true } } >
24
+ { children }
25
+ </ ProfileContext . Provider >
26
+ ) ;
20
27
const TestComponent = ( ) => {
21
28
const { isDocsButtonVisible, toggleDocs } = useDocsContext ( ) ;
22
29
return (
@@ -34,9 +41,11 @@ describe('InAppDocsProvider', () => {
34
41
it ( 'initially shows docs button and hide docs panel' , ( ) => {
35
42
render (
36
43
< MantineProvider >
37
- < InAppDocsProvider >
38
- < TestComponent />
39
- </ InAppDocsProvider >
44
+ < ProfileProvider >
45
+ < InAppDocsProvider >
46
+ < TestComponent />
47
+ </ InAppDocsProvider >
48
+ </ ProfileProvider >
40
49
</ MantineProvider > ,
41
50
) ;
42
51
@@ -47,9 +56,11 @@ describe('InAppDocsProvider', () => {
47
56
it ( 'after toggle: hides docs button and shows docs panel' , ( ) => {
48
57
render (
49
58
< MantineProvider >
50
- < InAppDocsProvider >
51
- < TestComponent />
52
- </ InAppDocsProvider >
59
+ < ProfileProvider >
60
+ < InAppDocsProvider >
61
+ < TestComponent />
62
+ </ InAppDocsProvider >
63
+ </ ProfileProvider >
53
64
</ MantineProvider > ,
54
65
) ;
55
66
@@ -61,9 +72,11 @@ describe('InAppDocsProvider', () => {
61
72
it ( 'close button: shows docs button and hides docs panel' , ( ) => {
62
73
render (
63
74
< MantineProvider >
64
- < InAppDocsProvider >
65
- < TestComponent />
66
- </ InAppDocsProvider >
75
+ < ProfileProvider >
76
+ < InAppDocsProvider >
77
+ < TestComponent />
78
+ </ InAppDocsProvider >
79
+ </ ProfileProvider >
67
80
</ MantineProvider > ,
68
81
) ;
69
82
0 commit comments