Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
[ACS-4412] Unit tests for createTags function (#1499)
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksanderSklorz committed Jan 26, 2023
1 parent 39b3c30 commit fea47c0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/content-services/tagApi.spec.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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();
});
});
});
16 changes: 16 additions & 0 deletions test/mockObjects/content-services/tag.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
}]);
}
}

0 comments on commit fea47c0

Please sign in to comment.