@@ -8,8 +8,8 @@ import { useToggle } from '@openedx/paragon';
88
99import { Sidebar } from '.' ;
1010
11- const Component1 = ( { text } : { text : string } ) => < div > Component 1 ( { text } ) </ div > ;
12- const Component2 = ( { text } : { text : string } ) => < div > Component 2 ( { text } ) </ div > ;
11+ const Component1 = ( ) => < div > Component 1</ div > ;
12+ const Component2 = ( ) => < div > Component 2</ div > ;
1313const Icon1 = ( ) => < div > Icon 1</ div > ;
1414const Icon2 = ( ) => < div > Icon 2</ div > ;
1515const pages = {
@@ -36,7 +36,6 @@ const TestSidebar = () => {
3636 setCurrentPageKey = { setPageKey }
3737 isOpen = { isOpen }
3838 toggle = { toggle }
39- contentProps = { { text : 'content props' } }
4039 />
4140 ) ;
4241} ;
@@ -50,7 +49,7 @@ describe('<Sidebar>', () => {
5049 render ( < TestSidebar /> ) ;
5150
5251 // Check the Page 1 content
53- expect ( screen . getByText ( 'Component 1 (content props) ' ) ) . toBeInTheDocument ( ) ;
52+ expect ( screen . getByText ( 'Component 1' ) ) . toBeInTheDocument ( ) ;
5453
5554 // Check the IconButtonToggle
5655 const sidebarToggle = screen . getByTestId ( 'sidebar-toggle' ) ;
@@ -69,22 +68,22 @@ describe('<Sidebar>', () => {
6968 render ( < TestSidebar /> ) ;
7069
7170 // Check the Page 1 content
72- expect ( screen . getByText ( 'Component 1 (content props) ' ) ) . toBeInTheDocument ( ) ;
71+ expect ( screen . getByText ( 'Component 1' ) ) . toBeInTheDocument ( ) ;
7372
7473 const page2Button = screen . getByRole ( 'button' , { name : 'Page 2' } ) ;
7574 await userEvent . click ( page2Button ) ;
7675
7776 expect ( page2Button ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
7877
7978 // Check the Page 2 content
80- expect ( screen . getByText ( 'Component 2 (content props) ' ) ) . toBeInTheDocument ( ) ;
79+ expect ( screen . getByText ( 'Component 2' ) ) . toBeInTheDocument ( ) ;
8180
8281 const page1Button = screen . getByRole ( 'button' , { name : 'Page 1' } ) ;
8382 expect ( page1Button ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
8483 await userEvent . click ( page1Button ) ;
8584
8685 // Check the Page 1 content
87- expect ( screen . getByText ( 'Component 1 (content props) ' ) ) . toBeInTheDocument ( ) ;
86+ expect ( screen . getByText ( 'Component 1' ) ) . toBeInTheDocument ( ) ;
8887 } ) ;
8988
9089 it ( 'should change pages using the dropdown button' , async ( ) => {
@@ -94,7 +93,7 @@ describe('<Sidebar>', () => {
9493 expect ( sidebarDropdown ) . toBeInTheDocument ( ) ;
9594
9695 // Check the Page 1 content
97- expect ( screen . getByText ( 'Component 1 (content props) ' ) ) . toBeInTheDocument ( ) ;
96+ expect ( screen . getByText ( 'Component 1' ) ) . toBeInTheDocument ( ) ;
9897
9998 // Click on the dropdown button
10099 await userEvent . click ( within ( sidebarDropdown ) . getByRole ( 'button' , { name : 'Page 1 Icon 1' } ) ) ;
@@ -104,7 +103,7 @@ describe('<Sidebar>', () => {
104103 await userEvent . click ( page2Button ) ;
105104
106105 // Check the Page 2 content
107- expect ( screen . getByText ( 'Component 2 (content props) ' ) ) . toBeInTheDocument ( ) ;
106+ expect ( screen . getByText ( 'Component 2' ) ) . toBeInTheDocument ( ) ;
108107
109108 // Click on the dropdown button again
110109 await userEvent . click ( within ( sidebarDropdown ) . getByRole ( 'button' , { name : 'Page 2 Icon 2' } ) ) ;
@@ -114,7 +113,7 @@ describe('<Sidebar>', () => {
114113 await userEvent . click ( page1Button ) ;
115114
116115 // Check the Page 1 content
117- expect ( screen . getByText ( 'Component 1 (content props) ' ) ) . toBeInTheDocument ( ) ;
116+ expect ( screen . getByText ( 'Component 1' ) ) . toBeInTheDocument ( ) ;
118117 } ) ;
119118
120119 it ( 'should toggle the sidebar' , async ( ) => {
@@ -124,20 +123,20 @@ describe('<Sidebar>', () => {
124123 expect ( sidebarToggle ) . toBeInTheDocument ( ) ;
125124
126125 // Check the Page 1 content
127- expect ( screen . getByText ( 'Component 1 (content props) ' ) ) . toBeInTheDocument ( ) ;
126+ expect ( screen . getByText ( 'Component 1' ) ) . toBeInTheDocument ( ) ;
128127
129128 // Hide the sidebar
130129 const toggleButton = within ( sidebarToggle ) . getByRole ( 'button' , { name : 'Toggle' } ) ;
131130 expect ( toggleButton ) . toBeInTheDocument ( ) ;
132131 await userEvent . click ( toggleButton ) ;
133132
134133 // Check the Page 1 content is hidden
135- expect ( screen . queryByText ( 'Component 1 (content props) ' ) ) . not . toBeInTheDocument ( ) ;
134+ expect ( screen . queryByText ( 'Component 1' ) ) . not . toBeInTheDocument ( ) ;
136135
137136 // Show the sidebar
138137 await userEvent . click ( toggleButton ) ;
139138
140139 // Check the Page 1 content
141- expect ( screen . getByText ( 'Component 1 (content props) ' ) ) . toBeInTheDocument ( ) ;
140+ expect ( screen . getByText ( 'Component 1' ) ) . toBeInTheDocument ( ) ;
142141 } ) ;
143142} ) ;
0 commit comments