-
Notifications
You must be signed in to change notification settings - Fork 18
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
e57189d
commit 0eb755e
Showing
4 changed files
with
103 additions
and
7 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
57 changes: 57 additions & 0 deletions
57
src/Configuration/Provisioning/DashboardDatatable/tests/DashboardTableActions.test.jsx
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* eslint-disable react/prop-types */ | ||
import { renderWithRouter } from '@edx/frontend-enterprise-utils'; | ||
import { fireEvent, screen } from '@testing-library/react'; | ||
import { Router } from 'react-router-dom'; | ||
import DashboardTableActions from '../DashboardTableActions'; | ||
import ROUTES from '../../../../data/constants/routes'; | ||
|
||
const { HOME } = ROUTES.CONFIGURATION.SUB_DIRECTORY.PROVISIONING; | ||
|
||
const useHistoryPush = jest.fn(); | ||
const historyMock = { | ||
push: useHistoryPush, | ||
location: jest.fn(), | ||
listen: jest.fn(), | ||
replace: jest.fn(), | ||
}; | ||
jest.mock('@edx/frontend-platform', () => ({ | ||
getConfig: () => { | ||
const DJANGO_ADMIN_SUBSIDY_BASE_URL = 'https://example.com'; | ||
return { | ||
DJANGO_ADMIN_SUBSIDY_BASE_URL, | ||
FEATURE_CONFIGURATION_EDIT_ENTERPRISE_PROVISION: true, | ||
}; | ||
}, | ||
})); | ||
|
||
const DashboardTableActionsWrapper = ({ | ||
row, | ||
}) => ( | ||
<Router history={historyMock}> | ||
<DashboardTableActions row={row} /> | ||
</Router> | ||
); | ||
|
||
describe('DashboardTableBadges', () => { | ||
it('renders', () => { | ||
const row = { | ||
values: { | ||
uuid: 'Pikachu', | ||
}, | ||
}; | ||
renderWithRouter(<DashboardTableActionsWrapper row={row} />); | ||
expect(screen.getByTestId(`Edit-${row.values.uuid}`)).toBeTruthy(); | ||
expect(screen.getByTestId(`Django-Admin-Page-${row.values.uuid}`)).toBeTruthy(); | ||
}); | ||
it('useHistory is called on click, Edit', async () => { | ||
const row = { | ||
values: { | ||
uuid: 'Pikachu', | ||
}, | ||
}; | ||
renderWithRouter(<DashboardTableActionsWrapper row={row} />); | ||
const editButton = screen.getByTestId(`Edit-${row.values.uuid}`); | ||
fireEvent.click(editButton); | ||
expect(useHistoryPush).toHaveBeenCalledWith(`${HOME}/${row.values.uuid}/edit`); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
src/Configuration/Provisioning/DashboardDatatable/tests/DashboardTableBadges.test.jsx
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { renderWithRouter } from '@edx/frontend-enterprise-utils'; | ||
import { screen } from '@testing-library/react'; | ||
import DashboardTableBadges from '../DashboardTableBadges'; | ||
|
||
describe('DashboardTableBadges', () => { | ||
it('renders the \'Active\' badge', () => { | ||
const row = { | ||
values: { | ||
isActive: true, | ||
}, | ||
}; | ||
renderWithRouter(<DashboardTableBadges row={row} />); | ||
expect(screen.getByText('Active')).toBeTruthy(); | ||
}); | ||
it('renders the \'Inactive\' badge', () => { | ||
const row = { | ||
values: { | ||
isActive: false, | ||
}, | ||
}; | ||
renderWithRouter(<DashboardTableBadges row={row} />); | ||
expect(screen.getByText('Inactive')).toBeTruthy(); | ||
}); | ||
}); |