[ACS-7706] create tags return promise tag paging instead of tag entry (#10869)

* [ACS-7706] Corrected returned type for createTags function

* [ACS-7706] Updated documentation for createTags and fixed unit tests
This commit is contained in:
AleksanderSklorz
2025-05-21 08:08:49 +02:00
committed by GitHub
parent 3fea334468
commit 2cc3ba4d6b
7 changed files with 20 additions and 22 deletions

View File

@@ -89,7 +89,7 @@ describe('TagService', () => {
describe('createTags', () => {
it('should call createTags on tagsApi', () => {
spyOn(service.tagsApi, 'createTags').and.returnValue(Promise.resolve([]));
spyOn(service.tagsApi, 'createTags').and.returnValue(Promise.resolve({}));
const tag1 = new TagBody();
tag1.tag = 'Some tag 1';
const tag2 = new TagBody();
@@ -101,19 +101,17 @@ describe('TagService', () => {
});
it('should emit refresh when tags creation is success', async () => {
const tags: TagEntry[] = [
{
entry: {
id: 'Some id 1',
tag: 'Some tag 1'
}
const tag: TagEntry = {
entry: {
id: 'Some id 1',
tag: 'Some tag 1'
}
];
};
spyOn(service.refresh, 'emit');
spyOn(service.tagsApi, 'createTags').and.returnValue(Promise.resolve(tags));
spyOn(service.tagsApi, 'createTags').and.returnValue(Promise.resolve(tag));
await service.createTags([]).toPromise();
expect(service.refresh.emit).toHaveBeenCalledWith(tags);
expect(service.refresh.emit).toHaveBeenCalledWith(tag);
});
});

View File

@@ -99,7 +99,7 @@ export class TagService {
* @param tags list of tags to create.
* @returns Created tags.
*/
createTags(tags: TagBody[]): Observable<TagEntry[]> {
createTags(tags: TagBody[]): Observable<TagEntry | TagPaging> {
return from(this.tagsApi.createTags(tags)).pipe(tap((tagEntries) => this.refresh.emit(tagEntries)));
}