11import {
2- render , screen , fireEvent , waitFor ,
2+ screen , fireEvent , waitFor ,
33} from '@testing-library/react' ;
4+ import { renderWrapper } from '@src/setupTest' ;
45import HeaderDescription from './HeaderDescription' ;
56
67jest . mock ( '@openedx/paragon' , ( ) => ( {
@@ -32,13 +33,13 @@ describe('HeaderDescription', () => {
3233
3334 describe ( 'Copy to clipboard' , ( ) => {
3435 it ( 'renders copy button if copyableDescription is true' , ( ) => {
35- render ( < HeaderDescription context = { { ...mockContext , copyableDescription : true } } info = { mockInfo } /> ) ;
36+ renderWrapper ( < HeaderDescription context = { { ...mockContext , copyableDescription : true } } info = { mockInfo } /> ) ;
3637 const copyButton = screen . getByRole ( 'button' , { name : 'Copy description' } ) ;
3738 expect ( copyButton ) . toBeInTheDocument ( ) ;
3839 } ) ;
3940
4041 it ( 'copies description to clipboard when copy button is clicked' , async ( ) => {
41- render ( < HeaderDescription context = { { ...mockContext , copyableDescription : true } } info = { mockInfo } /> ) ;
42+ renderWrapper ( < HeaderDescription context = { { ...mockContext , copyableDescription : true } } info = { mockInfo } /> ) ;
4243 const copyButton = screen . getByRole ( 'button' , { name : 'Copy description' } ) ;
4344 fireEvent . click ( copyButton ) ;
4445 await waitFor ( ( ) => {
@@ -49,17 +50,17 @@ describe('HeaderDescription', () => {
4950
5051 describe ( 'Basic Rendering' , ( ) => {
5152 it ( 'renders the context title' , ( ) => {
52- render ( < HeaderDescription context = { mockContext } info = { mockInfo } /> ) ;
53+ renderWrapper ( < HeaderDescription context = { mockContext } info = { mockInfo } /> ) ;
5354 expect ( screen . getByText ( mockContext . title ) ) . toBeInTheDocument ( ) ;
5455 } ) ;
5556
5657 it ( 'renders the context description' , ( ) => {
57- render ( < HeaderDescription context = { mockContext } info = { mockInfo } /> ) ;
58+ renderWrapper ( < HeaderDescription context = { mockContext } info = { mockInfo } /> ) ;
5859 expect ( screen . getByText ( mockContext . description ) ) . toBeInTheDocument ( ) ;
5960 } ) ;
6061
6162 it ( 'renders all info items' , ( ) => {
62- render ( < HeaderDescription context = { mockContext } info = { mockInfo } /> ) ;
63+ renderWrapper ( < HeaderDescription context = { mockContext } info = { mockInfo } /> ) ;
6364
6465 expect ( screen . getByText ( 'Catalogs' ) ) . toBeInTheDocument ( ) ;
6566 expect ( screen . getByText ( '5' ) ) . toBeInTheDocument ( ) ;
@@ -70,14 +71,14 @@ describe('HeaderDescription', () => {
7071 } ) ;
7172
7273 it ( 'handles empty info array' , ( ) => {
73- render ( < HeaderDescription context = { mockContext } info = { [ ] } /> ) ;
74+ renderWrapper ( < HeaderDescription context = { mockContext } info = { [ ] } /> ) ;
7475 expect ( screen . getByText ( mockContext . title ) ) . toBeInTheDocument ( ) ;
7576 } ) ;
7677 } ) ;
7778
7879 describe ( 'Image Handling' , ( ) => {
7980 it ( 'renders image when imageUrl is provided' , async ( ) => {
80- render ( < HeaderDescription context = { mockContext } info = { mockInfo } /> ) ;
81+ renderWrapper ( < HeaderDescription context = { mockContext } info = { mockInfo } /> ) ;
8182
8283 const imageContainer = await screen . findByTestId ( 'image-with-skeleton' ) ;
8384 expect ( imageContainer ) . toBeInTheDocument ( ) ;
@@ -87,7 +88,7 @@ describe('HeaderDescription', () => {
8788
8889 it ( 'does not render image when imageUrl is null' , ( ) => {
8990 const contextWithoutImage = { ...mockContext , imageUrl : null } ;
90- render ( < HeaderDescription context = { contextWithoutImage } info = { mockInfo } /> ) ;
91+ renderWrapper ( < HeaderDescription context = { contextWithoutImage } info = { mockInfo } /> ) ;
9192 expect ( screen . queryByTestId ( 'image-with-skeleton' ) ) . not . toBeInTheDocument ( ) ;
9293 } ) ;
9394 } ) ;
@@ -99,12 +100,12 @@ describe('HeaderDescription', () => {
99100 imageUrl : mockContext . imageUrl ,
100101 } ;
101102
102- render ( < HeaderDescription context = { contextWithoutDescription } info = { mockInfo } /> ) ;
103+ renderWrapper ( < HeaderDescription context = { contextWithoutDescription } info = { mockInfo } /> ) ;
103104 expect ( screen . getByText ( contextWithoutDescription . title ) ) . toBeInTheDocument ( ) ;
104105 } ) ;
105106
106107 it ( 'renders children when provided' , ( ) => {
107- render (
108+ renderWrapper (
108109 < HeaderDescription context = { mockContext } info = { mockInfo } >
109110 < div data-testid = "custom-children" > Custom content</ div >
110111 </ HeaderDescription > ,
0 commit comments