Skip to content

Commit e28a6ee

Browse files
committed
fix: Nits on the code
1 parent f666bbc commit e28a6ee

2 files changed

Lines changed: 35 additions & 8 deletions

File tree

src/course-unit/unit-sidebar/unit-info/UnitInfoSidebar.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,30 @@ describe('<UnitInfoSidebar /> - rendering', () => {
200200
expect(screen.getByText('Content Summary')).toBeInTheDocument();
201201
expect(screen.queryByText('Unit Content Summary')).not.toBeInTheDocument();
202202
});
203+
204+
it('shows Settings tab when isVertical is true', () => {
205+
unitSidebarContext.useUnitSidebarContext.mockReturnValue({
206+
currentTabKey: 'details',
207+
setCurrentTabKey: jest.fn(),
208+
isVertical: true,
209+
});
210+
211+
renderComponent();
212+
213+
expect(screen.getByRole('tab', { name: 'Settings' })).toBeInTheDocument();
214+
});
215+
216+
it('hides Settings tab when isVertical is false', () => {
217+
unitSidebarContext.useUnitSidebarContext.mockReturnValue({
218+
currentTabKey: 'details',
219+
setCurrentTabKey: jest.fn(),
220+
isVertical: false,
221+
});
222+
223+
renderComponent();
224+
225+
expect(screen.queryByRole('tab', { name: 'Settings' })).not.toBeInTheDocument();
226+
});
203227
});
204228

205229
describe('<UnitInfoSidebar /> - menu behavior', () => {

src/course-unit/unit-sidebar/unit-info/UnitInfoSidebar.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export const UnitInfoSidebar = () => {
121121
const currentItemData = useSelector(getCourseUnitData);
122122
const {
123123
currentTabKey,
124+
isVertical,
124125
setCurrentTabKey,
125126
} = useUnitSidebarContext();
126127
const { showToast } = useContext(ToastContext);
@@ -228,14 +229,16 @@ export const UnitInfoSidebar = () => {
228229
<UnitInfoDetails />
229230
</div>
230231
</Tab>
231-
<Tab
232-
eventKey="settings"
233-
title={intl.formatMessage(messages.sidebarInfoSettingsTab)}
234-
>
235-
<div className="mt-4">
236-
<UnitInfoSettings />
237-
</div>
238-
</Tab>
232+
{isVertical && (
233+
<Tab
234+
eventKey="settings"
235+
title={intl.formatMessage(messages.sidebarInfoSettingsTab)}
236+
>
237+
<div className="mt-4">
238+
<UnitInfoSettings />
239+
</div>
240+
</Tab>
241+
)}
239242
</Tabs>
240243
<DeleteModal
241244
isOpen={isDeleteModalOpen}

0 commit comments

Comments
 (0)