@@ -2,37 +2,29 @@ import { screen, render } from '@testing-library/react'
22import App from './App'
33
44// Mock the context to provide a client
5- jest . mock ( './context/FreshdeskClientContext' , ( ) => ( {
5+ jest . mock ( './context/FreshdeskClientContext/FreshdeskClientContext ' , ( ) => ( {
66 useFreshdeskClient : jest . fn ( )
77} ) )
88
99jest . mock ( '@freshworks/crayons/react' , ( ) => require ( '../__mocks__/freshworks-crayons-react' ) )
1010
11- test ( 'renders the app with HelloUser component' , ( ) => {
12- // Mock the context to return a client
13- const { useFreshdeskClient } = require ( './context/FreshdeskClientContext' )
14- useFreshdeskClient . mockReturnValue ( {
15- // Mock client object
16- } )
17-
18- render ( < App /> )
19-
20- // Check for the button text
21- const buttonElement = screen . getByText ( / g e t h e l p d e s k a c c o u n t / i)
22- expect ( buttonElement ) . toBeInTheDocument ( )
23-
24- // Check for the welcome text
25- const welcomeText = screen . getByText ( / w e l c o m e t o y o u r f i r s t r e a c t a p p i n f r e s h d e s k / i)
26- expect ( welcomeText ) . toBeInTheDocument ( )
11+ // Mock ResponseContainer component
12+ jest . mock ( './components/ResponseContainer/ResponseContainer' , ( ) => {
13+ return function MockResponseContainer ( ) {
14+ return 'MOCK_RESPONSE_CONTAINER'
15+ }
2716} )
2817
29- test ( 'renders loading state when client is not available' , ( ) => {
30- // Mock the context to return null client
31- const { useFreshdeskClient } = require ( './context/FreshdeskClientContext' )
32- useFreshdeskClient . mockReturnValue ( null )
18+ // Mock AccountConfigContext
19+ jest . mock ( './context/AccountConfigContext/AccountConfigContext' , ( ) => ( {
20+ AccountConfigProvider : ( { children } : { children : any } ) => children
21+ } ) )
22+
23+ test ( 'renders App component' , ( ) => {
24+ const { useFreshdeskClient } = require ( './context/FreshdeskClientContext/FreshdeskClientContext' )
25+ useFreshdeskClient . mockReturnValue ( { } )
3326
3427 render ( < App /> )
3528
36- const loadingElement = screen . getByText ( / l o a d i n g / i)
37- expect ( loadingElement ) . toBeInTheDocument ( )
29+ expect ( screen . getByText ( 'MOCK_RESPONSE_CONTAINER' ) ) . toBeInTheDocument ( )
3830} )
0 commit comments