Files
frontend-app-authoring/src/library-authoring/data/api.test.ts
Chris Chávez a37a1b1ef8 feat: Create collection Modal [FC-0062] (#1259)
* feat: Enable Collection button on Create Component in Library

* feat: CreateCollectionModal added

* test: For CreateCollectionModal

* refactor: Migrate FormikControl to TypeScript

* test: Add tests for EmptyStates
2024-09-13 21:07:02 -05:00

62 lines
1.8 KiB
TypeScript

import { initializeMocks } from '../../testUtils';
import * as api from './api';
describe('library data API', () => {
describe('createLibraryBlock', () => {
it('should create library block', async () => {
const { axiosMock } = initializeMocks();
const libraryId = 'lib:org:1';
const url = api.getCreateLibraryBlockUrl(libraryId);
axiosMock.onPost(url).reply(200);
await api.createLibraryBlock({
libraryId,
blockType: 'html',
definitionId: '1',
});
expect(axiosMock.history.post[0].url).toEqual(url);
});
});
describe('commitLibraryChanges', () => {
it('should commit library changes', async () => {
const { axiosMock } = initializeMocks();
const libraryId = 'lib:org:1';
const url = api.getCommitLibraryChangesUrl(libraryId);
axiosMock.onPost(url).reply(200);
await api.commitLibraryChanges(libraryId);
expect(axiosMock.history.post[0].url).toEqual(url);
});
});
describe('revertLibraryChanges', () => {
it('should revert library changes', async () => {
const { axiosMock } = initializeMocks();
const libraryId = 'lib:org:1';
const url = api.getCommitLibraryChangesUrl(libraryId);
axiosMock.onDelete(url).reply(200);
await api.revertLibraryChanges(libraryId);
expect(axiosMock.history.delete[0].url).toEqual(url);
});
});
it('should create collection', async () => {
const { axiosMock } = initializeMocks();
const libraryId = 'lib:org:1';
const url = api.getLibraryCollectionsApiUrl(libraryId);
axiosMock.onPost(url).reply(200);
await api.createCollection(libraryId, {
title: 'This is a test',
description: 'This is only a test',
});
expect(axiosMock.history.post[0].url).toEqual(url);
});
});