-
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.
Merge branch 'master' into mkeating/ENT-7580
- Loading branch information
Showing
9 changed files
with
128 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
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,8 @@ describe('<LearnerCreditAllocationTable />', () => { | |
enterpriseUUID: 'test-enterprise-id', | ||
isLoading: false, | ||
budgetType: 'OCM', | ||
enterpriseSlug: 'test-enterprise-slug', | ||
enableLearnerPortal: true, | ||
tableData: { | ||
results: [{ | ||
userEmail: '[email protected]', | ||
|
@@ -36,7 +42,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 +51,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 +71,63 @@ 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', | ||
enableLearnerPortal: true, | ||
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); | ||
}); | ||
|
||
it('does not render the course link if the learner portal is disabled', () => { | ||
const props = { | ||
enterpriseUUID: 'test-enterprise-id', | ||
isLoading: false, | ||
budgetType: 'OCM', | ||
enterpriseSlug: 'test-enterprise-slug', | ||
enableLearnerPortal: false, | ||
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 courseTitleElement = screen.queryByText('course-title'); | ||
expect(courseTitleElement.closest('a')).toBeNull(); | ||
}); | ||
}); |