Skip to content

Commit c1a3a9d

Browse files
committed
test: Adding new test to fix coverage
1 parent 9883f0a commit c1a3a9d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/course-outline/OutlineAddChildButtons.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ jest.mock('@src/course-outline/CourseOutlineContext', () => ({
3838
}));
3939

4040
const startCurrentFlow = jest.fn();
41+
const openContainerInfoSidebar = jest.fn();
4142
let currentFlow: OutlineFlow | null = null;
4243
jest.mock('@src/course-outline/outline-sidebar/OutlineSidebarContext', () => ({
4344
...jest.requireActual('@src/course-outline/outline-sidebar/OutlineSidebarContext'),
4445
useOutlineSidebarContext: () => ({
4546
...jest.requireActual('@src/course-outline/outline-sidebar/OutlineSidebarContext').useOutlineSidebarContext(),
4647
startCurrentFlow,
48+
openContainerInfoSidebar,
4749
currentFlow,
4850
isCurrentFlowOn: !!currentFlow,
4951
}),
@@ -113,6 +115,8 @@ jest.mock('@src/course-outline/outline-sidebar/OutlineSidebarContext', () => ({
113115
expect.objectContaining({ onSuccess: expect.any(Function) }),
114116
)
115117
);
118+
handleAddBlock.mutateAsync.mock.calls[0][1].onSuccess({ locator: 'new-section-id' });
119+
expect(openContainerInfoSidebar).toHaveBeenCalledWith('new-section-id', undefined, 'new-section-id');
116120
break;
117121
case ContainerType.Subsection:
118122
await waitFor(() =>
@@ -126,6 +130,12 @@ jest.mock('@src/course-outline/outline-sidebar/OutlineSidebarContext', () => ({
126130
expect.objectContaining({ onSuccess: expect.any(Function) }),
127131
)
128132
);
133+
handleAddBlock.mutateAsync.mock.calls[0][1].onSuccess({ locator: 'new-subsection-id' });
134+
expect(openContainerInfoSidebar).toHaveBeenCalledWith(
135+
'new-subsection-id',
136+
'new-subsection-id',
137+
parentLocator,
138+
);
129139
break;
130140
case ContainerType.Unit:
131141
await waitFor(() =>

src/course-outline/OutlineAddChildButtons.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ const NewOutlineAddChildButtons = ({
135135
parentLocator: courseUsageKey,
136136
displayName: COURSE_BLOCK_NAMES.chapter.name,
137137
}, {
138-
// istanbul ignore next
139138
onSuccess: (data: { locator: string; }) => {
140139
openContainerInfoSidebar(data.locator, undefined, data.locator);
141140
},
@@ -154,7 +153,6 @@ const NewOutlineAddChildButtons = ({
154153
displayName: COURSE_BLOCK_NAMES.sequential.name,
155154
sectionId: parentLocator,
156155
}, {
157-
// istanbul ignore next
158156
onSuccess: (data: { locator: string; }) => {
159157
openContainerInfoSidebar(data.locator, data.locator, parentLocator);
160158
},

0 commit comments

Comments
 (0)