mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-4411] updateTag method added to tags service (#8200)
* [ACS-4411] added updateTag method to tags service & tests & docs * [ACS-4411] docs formatting fix * [ACS-4411] unit test fix
This commit is contained in:
committed by
GitHub
parent
efb2558c3f
commit
b503773475
@@ -35,6 +35,11 @@ Manages tags in Content Services.
|
||||
Creates tags.
|
||||
- _tags:_ `TagBody[]` - List of tags to create.
|
||||
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<TagEntry[]>` - List of created tags.
|
||||
- **updateTag**(tagId: `string`, tagBody: `TagBody`): [`Observable`](http://reactivex.io/documentation/observable.html)`<TagEntry>`<br/>
|
||||
Updates a tag.
|
||||
- _tagId:_ `string` - The identifier of a tag.
|
||||
- _tagBody:_ `TagBody` - The updated tag.
|
||||
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<TagEntry>` - Updated tag.
|
||||
- **searchTags**(name: `string`, skipCount: `number`): [`Observable`](http://reactivex.io/documentation/observable.html)`<ResultSetPaging>`<br/>
|
||||
Find tags which name contains searched name.
|
||||
- _name:_ `string` - Value for name which should be used during searching tags.
|
||||
|
@@ -168,5 +168,46 @@ describe('TagService', () => {
|
||||
tick();
|
||||
}));
|
||||
});
|
||||
|
||||
describe('updateTag', () => {
|
||||
const tag: TagEntry = {
|
||||
entry: {
|
||||
tag: 'fake-tag',
|
||||
id: 'fake-node-id'
|
||||
}
|
||||
};
|
||||
const tagBody: TagBody = {tag: 'updated-tag'};
|
||||
const updatedTag: TagEntry = {
|
||||
entry: {
|
||||
...tagBody,
|
||||
id: 'fake-node-id'
|
||||
}
|
||||
};
|
||||
|
||||
it('should call updateTag on tagsApi', () => {
|
||||
spyOn(service.tagsApi, 'updateTag').and.returnValue(Promise.resolve(updatedTag));
|
||||
|
||||
service.updateTag(tag.entry.id, tagBody);
|
||||
expect(service.tagsApi.updateTag).toHaveBeenCalledWith(tag.entry.id, tagBody);
|
||||
});
|
||||
|
||||
it('should emit refresh when tag updated successfully', fakeAsync(() => {
|
||||
spyOn(service.refresh, 'emit');
|
||||
spyOn(service.tagsApi, 'updateTag').and.returnValue(Promise.resolve(updatedTag));
|
||||
service.updateTag(tag.entry.id, tagBody);
|
||||
tick();
|
||||
expect(service.refresh.emit).toHaveBeenCalledWith(updatedTag);
|
||||
}));
|
||||
|
||||
it('should call error on logService when error occurs during tag update', fakeAsync(() => {
|
||||
const logService: LogService = TestBed.inject(LogService);
|
||||
spyOn(logService, 'error');
|
||||
const error: string = 'Some error';
|
||||
spyOn(service.tagsApi, 'updateTag').and.returnValue(Promise.reject(error));
|
||||
service.updateTag(tag.entry.id, tagBody);
|
||||
tick();
|
||||
expect(logService.error).toHaveBeenCalledWith(error);
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -132,6 +132,22 @@ export class TagService {
|
||||
return observableAdd$;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a tag
|
||||
*
|
||||
* @param tagId The identifier of a tag.
|
||||
* @param tagBody The updated tag.
|
||||
* @returns Updated tag.
|
||||
*/
|
||||
updateTag(tagId: string, tagBody: TagBody): Observable<TagEntry> {
|
||||
const observableUpdate$: Observable<TagEntry> = from(this.tagsApi.updateTag(tagId, tagBody));
|
||||
observableUpdate$.subscribe(
|
||||
(tagEntry: TagEntry) => this.refresh.emit(tagEntry),
|
||||
(err) => this.handleError(err)
|
||||
);
|
||||
return observableUpdate$;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find tags which name contains searched name.
|
||||
*
|
||||
|
Reference in New Issue
Block a user