Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit fea47c0

Browse files
[ACS-4412] Unit tests for createTags function (#1499)
1 parent 39b3c30 commit fea47c0

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

test/content-services/tagApi.spec.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from 'chai';
22
import { AlfrescoApiConfig } from '../../src/alfrescoApiConfig';
33
import { AlfrescoApi } from '../../src/alfrescoApi';
4-
import { TagsApi } from '../../src/api/content-rest-api';
4+
import { TagBody, TagEntry, TagsApi } from '../../src/api/content-rest-api';
55
import { EcmAuthMock, TagMock } from '../../test/mockObjects';
66

77
describe('Tags', () => {
@@ -49,4 +49,20 @@ describe('Tags', () => {
4949
}
5050
);
5151
});
52+
53+
describe('createTags', () => {
54+
it('should return created tags', (done: Mocha.Done) => {
55+
tagMock.createTags201Response();
56+
tagsApi.createTags([new TagBody(), new TagBody()]).then((tags: TagEntry[]) => {
57+
expect(tags).length(2);
58+
expect(tags[0].entry.tag).equal('tag-test-1');
59+
expect(tags[1].entry.tag).equal('tag-test-2');
60+
done();
61+
});
62+
});
63+
64+
it('should throw error if tags are not passed', () => {
65+
expect(tagsApi.createTags.bind(tagsApi, null)).throw();
66+
});
67+
});
5268
});

test/mockObjects/content-services/tag.mock.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,20 @@ export class TagMock extends BaseMock {
4343
},
4444
});
4545
}
46+
47+
createTags201Response(): void {
48+
nock(this.host, { encodedQueryParams: true })
49+
.post('/alfresco/api/-default-/public/alfresco/versions/1/tags')
50+
.reply(201, [{
51+
entry: {
52+
tag: 'tag-test-1',
53+
id: '0d89aa82-f2b8-4a37-9a54-f4c5148174d6',
54+
},
55+
}, {
56+
entry: {
57+
tag: 'tag-test-2',
58+
id: 'd79bdbd0-9f55-45bb-9521-811e15bf48f6',
59+
},
60+
}]);
61+
}
4662
}

0 commit comments

Comments
 (0)