Skip to content

Commit

Permalink
test: fix CoursewareRedirectLandingPage and ActiveEnterpriseAlert tes…
Browse files Browse the repository at this point in the history
…t cases
  • Loading branch information
dcoa committed Oct 21, 2022
1 parent d519362 commit 29964ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('ActiveEnterpriseAlert', () => {
it('Shows alert message and links', () => {
render(<ActiveEnterpriseAlert {...mockData} />);
expect(screen.getByRole('alert')).toBeInTheDocument();
expect(screen.getByText('test message')).toBeInTheDocument();
expect(screen.getByRole('alert').textContent).toBe(`${mockData.payload.text} change enterprise now.`);
expect(screen.getByRole('link', { name: 'change enterprise now' })).toHaveAttribute(
'href', `${getConfig().LMS_BASE_URL}/enterprise/select/active/?success_url=http%3A%2F%2Flocalhost%2Fcourse%2Ftest-course-id%2Fhome`,
);
Expand Down
3 changes: 2 additions & 1 deletion src/courseware/CoursewareRedirectLandingPage.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import { Router } from 'react-router';
import { createMemoryHistory } from 'history';
import { render, initializeMockApp } from '../setupTest';
import CoursewareRedirectLandingPage from './CoursewareRedirectLandingPage';

const redirectUrl = jest.fn();
Expand All @@ -17,6 +17,7 @@ jest.mock('react-router', () => ({

describe('CoursewareRedirectLandingPage', () => {
beforeEach(async () => {
await initializeMockApp();
delete global.location;
global.location = { assign: redirectUrl };
});
Expand Down

0 comments on commit 29964ac

Please sign in to comment.