-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
062c513
commit b0f55c9
Showing
3 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,28 @@ import { | |
render, | ||
} from '@testing-library/react'; | ||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
import { Provider } from 'react-redux'; | ||
import configureMockStore from 'redux-mock-store'; | ||
|
||
import LearnerCreditAllocationTable from '../LearnerCreditAllocationTable'; | ||
|
||
const mockStore = configureMockStore(); | ||
const store = mockStore({ | ||
portalConfiguration: { | ||
enterpriseSlug: 'test-enterprise-slug', | ||
}, | ||
}); | ||
|
||
jest.mock('@edx/frontend-platform/config', () => ({ | ||
getConfig: () => ({ ENTERPRISE_LEARNER_PORTAL_URL: 'https://enterprise.edx.org' }), | ||
})); | ||
|
||
const LearnerCreditAllocationTableWrapper = (props) => ( | ||
<IntlProvider locale="en"> | ||
<LearnerCreditAllocationTable {...props} /> | ||
</IntlProvider> | ||
<Provider store={store}> | ||
<IntlProvider locale="en"> | ||
<LearnerCreditAllocationTable {...props} /> | ||
</IntlProvider> | ||
</Provider> | ||
); | ||
|
||
describe('<LearnerCreditAllocationTable />', () => { | ||
|
@@ -65,4 +80,33 @@ describe('<LearnerCreditAllocationTable />', () => { | |
|
||
expect(screen.getByText('No results found', { exact: false })); | ||
}); | ||
|
||
it('constructs the correct URL for the course', () => { | ||
const props = { | ||
enterpriseUUID: 'test-enterprise-id', | ||
isLoading: false, | ||
budgetType: 'OCM', | ||
tableData: { | ||
results: [{ | ||
userEmail: '[email protected]', | ||
courseTitle: 'course-title', | ||
courseKey: 'course-v1:edX=CTL.SC101x.3T2019', | ||
courseListPrice: 100, | ||
enrollmentDate: '2-2-23', | ||
courseProductLine: 'OCM', | ||
}], | ||
itemCount: 1, | ||
pageCount: 1, | ||
}, | ||
fetchTableData: jest.fn(), | ||
}; | ||
props.fetchTableData.mockReturnValue(props.tableData); | ||
|
||
render(<LearnerCreditAllocationTableWrapper {...props} />); | ||
|
||
const expectedLink = 'https://enterprise.edx.org/test-enterprise-slug/course/course-v1:edX=CTL.SC101x.3T2019'; | ||
const courseLinkElement = screen.getByText('course-title'); | ||
|
||
expect(courseLinkElement.getAttribute('href')).toBe(expectedLink); | ||
}); | ||
}); |