diff --git a/test/content-services/tagApi.spec.ts b/test/content-services/tagApi.spec.ts index bb428041af..1a4c85eab4 100644 --- a/test/content-services/tagApi.spec.ts +++ b/test/content-services/tagApi.spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { AlfrescoApiConfig } from '../../src/alfrescoApiConfig'; import { AlfrescoApi } from '../../src/alfrescoApi'; -import { TagsApi } from '../../src/api/content-rest-api'; +import { TagBody, TagEntry, TagsApi } from '../../src/api/content-rest-api'; import { EcmAuthMock, TagMock } from '../../test/mockObjects'; describe('Tags', () => { @@ -49,4 +49,20 @@ describe('Tags', () => { } ); }); + + describe('createTags', () => { + it('should return created tags', (done: Mocha.Done) => { + tagMock.createTags201Response(); + tagsApi.createTags([new TagBody(), new TagBody()]).then((tags: TagEntry[]) => { + expect(tags).length(2); + expect(tags[0].entry.tag).equal('tag-test-1'); + expect(tags[1].entry.tag).equal('tag-test-2'); + done(); + }); + }); + + it('should throw error if tags are not passed', () => { + expect(tagsApi.createTags.bind(tagsApi, null)).throw(); + }); + }); }); diff --git a/test/mockObjects/content-services/tag.mock.ts b/test/mockObjects/content-services/tag.mock.ts index 7c923843fa..bbdbcb510f 100644 --- a/test/mockObjects/content-services/tag.mock.ts +++ b/test/mockObjects/content-services/tag.mock.ts @@ -43,4 +43,20 @@ export class TagMock extends BaseMock { }, }); } + + createTags201Response(): void { + nock(this.host, { encodedQueryParams: true }) + .post('/alfresco/api/-default-/public/alfresco/versions/1/tags') + .reply(201, [{ + entry: { + tag: 'tag-test-1', + id: '0d89aa82-f2b8-4a37-9a54-f4c5148174d6', + }, + }, { + entry: { + tag: 'tag-test-2', + id: 'd79bdbd0-9f55-45bb-9521-811e15bf48f6', + }, + }]); + } }