-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor LearnerCreditAllocationTable (#1019)
* chore: refactor LCM data table
- Loading branch information
1 parent
9af4648
commit ef1692d
Showing
7 changed files
with
79 additions
and
35 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
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
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 |
---|---|---|
|
@@ -7,6 +7,10 @@ import { IntlProvider } from '@edx/frontend-platform/i18n'; | |
|
||
import LearnerCreditAllocationTable from '../LearnerCreditAllocationTable'; | ||
|
||
jest.mock('@edx/frontend-platform/config', () => ({ | ||
getConfig: () => ({ ENTERPRISE_LEARNER_PORTAL_URL: 'https://enterprise.edx.org' }), | ||
})); | ||
|
||
const LearnerCreditAllocationTableWrapper = (props) => ( | ||
<IntlProvider locale="en"> | ||
<LearnerCreditAllocationTable {...props} /> | ||
|
@@ -19,6 +23,7 @@ describe('<LearnerCreditAllocationTable />', () => { | |
enterpriseUUID: 'test-enterprise-id', | ||
isLoading: false, | ||
budgetType: 'OCM', | ||
enterpriseSlug: 'test-enterprise-slug', | ||
tableData: { | ||
results: [{ | ||
userEmail: '[email protected]', | ||
|
@@ -36,7 +41,6 @@ describe('<LearnerCreditAllocationTable />', () => { | |
|
||
render(<LearnerCreditAllocationTableWrapper {...props} />); | ||
|
||
expect(screen.getByText('Open', { exact: false })); | ||
expect(screen.getByText(props.tableData.results[0].userEmail.toString(), { | ||
exact: false, | ||
})); | ||
|
@@ -46,7 +50,7 @@ describe('<LearnerCreditAllocationTable />', () => { | |
expect(screen.getByText(props.tableData.results[0].courseListPrice.toString(), { | ||
exact: false, | ||
})); | ||
expect(screen.getByText('February', { exact: false })); | ||
expect(screen.getByText('Feb', { exact: false })); | ||
}); | ||
it('renders with empty table data', () => { | ||
const props = { | ||
|
@@ -66,4 +70,34 @@ 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', | ||
enterpriseSlug: 'test-enterprise-slug', | ||
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); | ||
}); | ||
}); |