forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
3 changed files
with
54 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import { IntlProvider, injectIntl } from '@edx/frontend-platform/i18n'; | ||
import { initializeMockApp } from '@edx/frontend-platform'; | ||
import { AppProvider } from '@edx/frontend-platform/react'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
import ExportModal from './ExportModal'; | ||
import initializeStore from '../../store'; | ||
import { callExportTaxonomy } from '../api/hooks/selectors'; | ||
|
||
const onClose = jest.fn(); | ||
let store; | ||
const taxonomyId = 1; | ||
|
||
jest.mock('../api/hooks/selectors', () => ({ | ||
callExportTaxonomy: jest.fn(), | ||
})); | ||
|
||
const ExportModalComponent = () => ( | ||
<AppProvider store={store}> | ||
<IntlProvider locale="en" messages={{}}> | ||
<ExportModal intl={injectIntl} taxonomyId={taxonomyId} onClose={onClose} isOpen /> | ||
</IntlProvider> | ||
</AppProvider> | ||
); | ||
|
||
describe('<ExportModal />', async () => { | ||
beforeEach(async () => { | ||
initializeMockApp({ | ||
authenticatedUser: { | ||
userId: 3, | ||
username: 'abc123', | ||
administrator: true, | ||
roles: [], | ||
}, | ||
}); | ||
store = initializeStore(); | ||
}); | ||
|
||
it('should render the modal', () => { | ||
const { getByText } = render(<ExportModalComponent />); | ||
expect(getByText('Select format to export')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call export endpoint', () => { | ||
const { getByText } = render(<ExportModalComponent />); | ||
|
||
fireEvent.click(getByText('JSON file')); | ||
fireEvent.click(getByText('Export')); | ||
|
||
expect(onClose).toHaveBeenCalled(); | ||
expect(callExportTaxonomy).toHaveBeenCalledWith(taxonomyId, 'json'); | ||
}); | ||
}); |
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