feat: Taxonomy export menu [FC-0036] (#645)
* feat: System-defined tooltip added * feat: Taxonomy card menu added. Export menu item added * feat: Modal for export taxonomy * feat: Connect with export API * test: Tests for API and selectors * feat: Use windows.location.href to call the export endpoint * test: ExportModal.test added * style: Delete unnecessary code * docs: README updated with taxonomy feature * style: TaxonomyCard updated to a better code style * style: injectIntl replaced by useIntl on taxonomy pages and components * refactor: Move and rename taxonomy UI components to match 0002 ADR * refactor: Move api to data to match with 0002 ADR * test: Refactor ExportModal tests * chore: Fix validations * chore: Lint * refactor: Moving hooks to apiHooks * style: Nit on return null --------- Co-authored-by: Rômulo Penido <romulo@dash.dev.br> Co-authored-by: Christofer Chavez <christofer@example.com>
This commit is contained in:
61
src/taxonomy/data/api.test.js
Normal file
61
src/taxonomy/data/api.test.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import MockAdapter from 'axios-mock-adapter';
|
||||
import { initializeMockApp } from '@edx/frontend-platform';
|
||||
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
|
||||
|
||||
import { taxonomyListMock } from '../__mocks__';
|
||||
|
||||
import {
|
||||
getTaxonomyListApiUrl,
|
||||
getExportTaxonomyApiUrl,
|
||||
getTaxonomyListData,
|
||||
getTaxonomyExportFile,
|
||||
} from './api';
|
||||
|
||||
let axiosMock;
|
||||
|
||||
describe('taxonomy api calls', () => {
|
||||
const { location } = window;
|
||||
beforeEach(() => {
|
||||
initializeMockApp({
|
||||
authenticatedUser: {
|
||||
userId: 3,
|
||||
username: 'abc123',
|
||||
administrator: true,
|
||||
roles: [],
|
||||
},
|
||||
});
|
||||
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
beforeAll(() => {
|
||||
delete window.location;
|
||||
window.location = {
|
||||
href: '',
|
||||
};
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
window.location = location;
|
||||
});
|
||||
|
||||
it('should get taxonomy list data', async () => {
|
||||
axiosMock.onGet(getTaxonomyListApiUrl()).reply(200, taxonomyListMock);
|
||||
const result = await getTaxonomyListData();
|
||||
|
||||
expect(axiosMock.history.get[0].url).toEqual(getTaxonomyListApiUrl());
|
||||
expect(result).toEqual(taxonomyListMock);
|
||||
});
|
||||
|
||||
it('should set window.location.href correctly', () => {
|
||||
const pk = 1;
|
||||
const format = 'json';
|
||||
|
||||
getTaxonomyExportFile(pk, format);
|
||||
|
||||
expect(window.location.href).toEqual(getExportTaxonomyApiUrl(pk, format));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user