1+ import { getConfig , setConfig } from '@edx/frontend-platform' ;
12import {
23 act , fireEvent , initializeMocks , render , screen , waitFor , within ,
34} from '@src/testUtils' ;
45import { XBlock } from '@src/data/types' ;
56import SectionCard from './SectionCard' ;
7+ import { OutlineSidebarProvider } from '../outline-sidebar/OutlineSidebarContext' ;
68
79const mockUseAcceptLibraryBlockChanges = jest . fn ( ) ;
810const mockUseIgnoreLibraryBlockChanges = jest . fn ( ) ;
@@ -116,6 +118,7 @@ const renderComponent = (props?: object, entry = '/course/:courseId') => render(
116118 routerProps : {
117119 initialEntries : [ entry ] ,
118120 } ,
121+ extraWrapper : OutlineSidebarProvider ,
119122 } ,
120123) ;
121124
@@ -129,6 +132,32 @@ describe('<SectionCard />', () => {
129132
130133 expect ( screen . getByTestId ( 'section-card-header' ) ) . toBeInTheDocument ( ) ;
131134 expect ( screen . getByTestId ( 'section-card__content' ) ) . toBeInTheDocument ( ) ;
135+
136+ // The card is not selected
137+ const card = screen . getByTestId ( 'section-card' ) ;
138+ expect ( card ) . not . toHaveClass ( 'outline-card-selected' ) ;
139+ } ) ;
140+
141+ it ( 'render SectionCard component in selected state' , ( ) => {
142+ setConfig ( {
143+ ...getConfig ( ) ,
144+ ENABLE_COURSE_OUTLINE_NEW_DESIGN : 'true' ,
145+ } ) ;
146+ const { container } = renderComponent ( ) ;
147+
148+ expect ( screen . getByTestId ( 'section-card-header' ) ) . toBeInTheDocument ( ) ;
149+
150+ // The card is not selected
151+ const card = screen . getByTestId ( 'section-card' ) ;
152+ expect ( card ) . not . toHaveClass ( 'outline-card-selected' ) ;
153+
154+ // Get the <Row> that contains the card and click it to select the card
155+ const el = container . querySelector ( 'div.row.mx-0' ) as HTMLInputElement ;
156+ expect ( el ) . not . toBeNull ( ) ;
157+ fireEvent . click ( el ! ) ;
158+
159+ // The card is selected
160+ expect ( card ) . toHaveClass ( 'outline-card-selected' ) ;
132161 } ) ;
133162
134163 it ( 'expands/collapses the card when the expand button is clicked' , ( ) => {
0 commit comments