mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-02 17:53:30 +00:00
66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
/*!
|
|
* @license
|
|
* Copyright © 2005-2026 Hyland Software, Inc. and its affiliates. All rights reserved.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import assert from 'assert';
|
|
import { resetGlobalMockAgent } from '../mockObjects/base.mock';
|
|
import { AlfrescoApi, CommentsApi } from '../../src';
|
|
import { CommentMock, EcmAuthMock } from '../mockObjects';
|
|
import { describe, it, beforeEach, afterEach } from 'node:test';
|
|
|
|
describe('Comments', () => {
|
|
let authResponseMock: EcmAuthMock;
|
|
let commentMock: CommentMock;
|
|
let commentsApi: CommentsApi;
|
|
|
|
beforeEach(async () => {
|
|
const hostEcm = 'https://127.0.0.1:8080';
|
|
|
|
authResponseMock = new EcmAuthMock(hostEcm);
|
|
commentMock = new CommentMock(hostEcm);
|
|
|
|
authResponseMock.get201Response();
|
|
|
|
const alfrescoJsApi = new AlfrescoApi({
|
|
hostEcm
|
|
});
|
|
|
|
commentsApi = new CommentsApi(alfrescoJsApi);
|
|
|
|
await alfrescoJsApi.login('admin', 'admin');
|
|
});
|
|
|
|
afterEach(() => {
|
|
resetGlobalMockAgent();
|
|
});
|
|
|
|
it('should add a comment', async () => {
|
|
commentMock.post201Response();
|
|
|
|
const data = await commentsApi.createComment('74cd8a96-8a21-47e5-9b3b-a1b3e296787d', {
|
|
content: 'This is a comment'
|
|
});
|
|
assert.equal(data.entry.content, 'This is a comment');
|
|
});
|
|
|
|
it('should get a comment', async () => {
|
|
commentMock.get200Response();
|
|
|
|
const data = await commentsApi.listComments('74cd8a96-8a21-47e5-9b3b-a1b3e296787d');
|
|
assert.equal(data.list.entries[0].entry.content, 'This is another comment');
|
|
});
|
|
});
|