Skip to content

Commit 4f117df

Browse files
committed
test: fix minor issues with tests
1 parent 21cb518 commit 4f117df

File tree

6 files changed

+8
-30
lines changed

6 files changed

+8
-30
lines changed

src/containers/CourseCard/components/CourseCardActions/index.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jest.mock('@src/hooks', () => ({
1212
},
1313
}));
1414

15-
jest.mock('../../../../slots/CourseCardActionSlot', () => jest.fn(() => <div>CourseCardActionSlot</div>));
15+
jest.mock('@src/slots/CourseCardActionSlot', () => jest.fn(() => <div>CourseCardActionSlot</div>));
1616
jest.mock('./SelectSessionButton', () => jest.fn(() => <div>SelectSessionButton</div>));
1717
jest.mock('./ViewCourseButton', () => jest.fn(() => <div>ViewCourseButton</div>));
1818
jest.mock('./BeginCourseButton', () => jest.fn(() => <div>BeginCourseButton</div>));

src/containers/CourseCard/components/CourseCardDetails/hooks.test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ describe('CourseCardDetails hooks', () => {
4545
});
4646

4747
describe('useCardDetailsData', () => {
48-
const providerData = {
49-
name: 'Unknown',
50-
};
48+
const providerName = 'my-provider-name';
49+
const providerData = {};
5150
const entitlementData = {
5251
isEntitlement: false,
5352
disableViewCourse: false,
@@ -77,8 +76,10 @@ describe('CourseCardDetails hooks', () => {
7776
expect(out.accessMessage).toEqual(mockAccessMessage({ cardId }));
7877
});
7978
it('forwards provider name if it exists, else formatted unknown provider name', () => {
80-
expect(out.providerName).toEqual(providerData.name);
81-
runHook({ provider: { name: providerData.name } });
79+
runHook({ provider: { name: providerName } });
80+
expect(out.providerName).toEqual(providerName);
81+
82+
runHook({ provider: {} });
8283
expect(out.providerName).toEqual(formatMessage(messages.unknownProviderName));
8384
});
8485
it('forward changeOrLeaveSessionMessage', () => {

src/containers/CourseCard/components/CourseCardMenu/SocialShareMenu.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe('SocialShareMenu', () => {
116116
expect(emailSettingsButton).toBeInTheDocument();
117117
});
118118
if (isMasquerading) {
119-
it('renders when masquerading', () => {
119+
it('is disabled', () => {
120120
const emailSettingsButton = screen.getByRole('button', { name: messages.emailSettings.defaultMessage });
121121
expect(emailSettingsButton).toBeInTheDocument();
122122
expect(emailSettingsButton).toHaveAttribute('aria-disabled', 'true');

src/containers/CourseCard/components/CourseCardMenu/index.test.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import messages from './messages';
1010

1111
jest.mock('@src/hooks', () => ({
1212
reduxHooks: {
13-
1413
useCardEnrollmentData: jest.fn(),
1514
},
1615
}));

src/setupTest.jsx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,3 @@ jest.mock('react-redux', () => {
4343
useSelector: jest.fn((selector) => ({ useSelector: selector })),
4444
};
4545
});
46-
47-
jest.mock('./data/constants/app', () => ({
48-
...jest.requireActual('./data/constants/app'),
49-
locationId: 'fake-location-id',
50-
}));
51-
52-
jest.mock('./utils', () => ({
53-
...jest.requireActual('./utils'),
54-
nullMethod: jest.fn().mockName('utils.nullMethod'),
55-
}));
56-
57-
jest.mock('./utils/hooks', () => {
58-
const formatDate = jest.fn(date => new Date(date).toLocaleDateString())
59-
.mockName('utils.formatDate');
60-
return {
61-
formatDate,
62-
useFormatDate: () => formatDate,
63-
};
64-
});

src/utils/StrictDict.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,5 @@ describe('StrictDict', () => {
5454
// Accessing a missing key should return undefined
5555
expect(dict.fakeKey).toBeUndefined();
5656
});
57-
it('returns undefined', () => {
58-
expect(dict.fakeKey).toEqual(undefined);
59-
});
6057
});
6158
});

0 commit comments

Comments
 (0)