Skip to content

Commit

Permalink
chore: Added test for Xpert to use the bew hook
Browse files Browse the repository at this point in the history
  • Loading branch information
rijuma committed Nov 12, 2024
1 parent 6498378 commit da4904a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/widgets/Xpert.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Xpert from './Xpert';
import * as surveyMonkey from '../utils/surveyMonkey';
import { render, createRandomResponseForTesting } from '../utils/utils.test';
import { usePromptExperimentDecision } from '../experiments';
import { useMessageHistory } from '../hooks';

jest.mock('@edx/frontend-platform/analytics');
jest.mock('@edx/frontend-platform/auth', () => ({
Expand All @@ -20,6 +21,8 @@ jest.mock('../experiments', () => ({
usePromptExperimentDecision: jest.fn(),
}));

jest.mock('../hooks');

const initialState = {
learningAssistant: {
currentMessage: '',
Expand Down Expand Up @@ -76,6 +79,11 @@ test('initial load displays correct elements', async () => {
// assert that UI elements in the sidebar are not in the DOM
assertSidebarElementsNotInDOM();
});
test('calls useMessageHistory() hook', () => {
render(<Xpert courseId={courseId} contentToolsEnabled={false} unitId={unitId} />, { preloadedState: initialState });

expect(useMessageHistory).toHaveBeenCalledWith(courseId);
});
test('clicking the call to action dismiss button removes the message', async () => {
const user = userEvent.setup();
render(<Xpert courseId={courseId} contentToolsEnabled={false} unitId={unitId} />, { preloadedState: initialState });
Expand Down

0 comments on commit da4904a

Please sign in to comment.