test: fix minor issues with tests
This commit is contained in:
committed by
Adolfo R. Brandes
parent
21cb51861d
commit
4f117dfc96
@@ -12,7 +12,7 @@ jest.mock('@src/hooks', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('../../../../slots/CourseCardActionSlot', () => jest.fn(() => <div>CourseCardActionSlot</div>));
|
||||
jest.mock('@src/slots/CourseCardActionSlot', () => jest.fn(() => <div>CourseCardActionSlot</div>));
|
||||
jest.mock('./SelectSessionButton', () => jest.fn(() => <div>SelectSessionButton</div>));
|
||||
jest.mock('./ViewCourseButton', () => jest.fn(() => <div>ViewCourseButton</div>));
|
||||
jest.mock('./BeginCourseButton', () => jest.fn(() => <div>BeginCourseButton</div>));
|
||||
|
||||
@@ -45,9 +45,8 @@ describe('CourseCardDetails hooks', () => {
|
||||
});
|
||||
|
||||
describe('useCardDetailsData', () => {
|
||||
const providerData = {
|
||||
name: 'Unknown',
|
||||
};
|
||||
const providerName = 'my-provider-name';
|
||||
const providerData = {};
|
||||
const entitlementData = {
|
||||
isEntitlement: false,
|
||||
disableViewCourse: false,
|
||||
@@ -77,8 +76,10 @@ describe('CourseCardDetails hooks', () => {
|
||||
expect(out.accessMessage).toEqual(mockAccessMessage({ cardId }));
|
||||
});
|
||||
it('forwards provider name if it exists, else formatted unknown provider name', () => {
|
||||
expect(out.providerName).toEqual(providerData.name);
|
||||
runHook({ provider: { name: providerData.name } });
|
||||
runHook({ provider: { name: providerName } });
|
||||
expect(out.providerName).toEqual(providerName);
|
||||
|
||||
runHook({ provider: {} });
|
||||
expect(out.providerName).toEqual(formatMessage(messages.unknownProviderName));
|
||||
});
|
||||
it('forward changeOrLeaveSessionMessage', () => {
|
||||
|
||||
@@ -116,7 +116,7 @@ describe('SocialShareMenu', () => {
|
||||
expect(emailSettingsButton).toBeInTheDocument();
|
||||
});
|
||||
if (isMasquerading) {
|
||||
it('renders when masquerading', () => {
|
||||
it('is disabled', () => {
|
||||
const emailSettingsButton = screen.getByRole('button', { name: messages.emailSettings.defaultMessage });
|
||||
expect(emailSettingsButton).toBeInTheDocument();
|
||||
expect(emailSettingsButton).toHaveAttribute('aria-disabled', 'true');
|
||||
|
||||
@@ -10,7 +10,6 @@ import messages from './messages';
|
||||
|
||||
jest.mock('@src/hooks', () => ({
|
||||
reduxHooks: {
|
||||
|
||||
useCardEnrollmentData: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -43,22 +43,3 @@ jest.mock('react-redux', () => {
|
||||
useSelector: jest.fn((selector) => ({ useSelector: selector })),
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('./data/constants/app', () => ({
|
||||
...jest.requireActual('./data/constants/app'),
|
||||
locationId: 'fake-location-id',
|
||||
}));
|
||||
|
||||
jest.mock('./utils', () => ({
|
||||
...jest.requireActual('./utils'),
|
||||
nullMethod: jest.fn().mockName('utils.nullMethod'),
|
||||
}));
|
||||
|
||||
jest.mock('./utils/hooks', () => {
|
||||
const formatDate = jest.fn(date => new Date(date).toLocaleDateString())
|
||||
.mockName('utils.formatDate');
|
||||
return {
|
||||
formatDate,
|
||||
useFormatDate: () => formatDate,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -54,8 +54,5 @@ describe('StrictDict', () => {
|
||||
// Accessing a missing key should return undefined
|
||||
expect(dict.fakeKey).toBeUndefined();
|
||||
});
|
||||
it('returns undefined', () => {
|
||||
expect(dict.fakeKey).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user