diff --git a/src/lib/components/ContentLink.spec.ts b/src/lib/components/ContentLink.spec.ts index deddda6..1e6032a 100644 --- a/src/lib/components/ContentLink.spec.ts +++ b/src/lib/components/ContentLink.spec.ts @@ -49,7 +49,7 @@ describe('ContentItem', () => { it('should beable to return multiple items', () => { jest.spyOn(connection, 'request').mockResolvedValue({}); - contentLink.getMultiple(['123'], { pointer: '/fieldPointer', max: null }); + contentLink.getMultiple(['123'], { pointer: '/fieldPointer' }); expect(connection.request).toHaveBeenCalledWith( CONTENT_LINK.CONTENT_GET, diff --git a/src/lib/components/ContentLink.ts b/src/lib/components/ContentLink.ts index ae0f3f6..5be5f54 100644 --- a/src/lib/components/ContentLink.ts +++ b/src/lib/components/ContentLink.ts @@ -38,12 +38,16 @@ export class ContentLink { */ getMultiple( contentTypeIds: Array, - options: ContentLinkOptions = { max: null, pointer: '' } + options: ContentLinkOptions ): Promise { - if (options.max === undefined) { - options.max = null; + const defaultOptions = { + max: null } - return this.fetchLinks(contentTypeIds, options.pointer, options.max); + const mergedOptions = { + ...defaultOptions, + ...options + } + return this.fetchLinks(contentTypeIds, mergedOptions.pointer, mergedOptions.max); } /** * This method will trigger a content browser. It returns a promise that will resolve to the chosen Content Link. diff --git a/src/lib/components/ContentReference.spec.ts b/src/lib/components/ContentReference.spec.ts index 9e5f867..2c53b4d 100644 --- a/src/lib/components/ContentReference.spec.ts +++ b/src/lib/components/ContentReference.spec.ts @@ -48,7 +48,7 @@ describe('ContentReference', () => { it('should beable to return multiple items', async () => { jest.spyOn(connection, 'request').mockResolvedValue({}); - await expect(contentReference.getMultiple(['123'], { max: null, pointer: '/fieldPointer' })).resolves.toEqual({}); + await expect(contentReference.getMultiple(['123'], { pointer: '/fieldPointer' })).resolves.toEqual({}); expect(connection.request).toHaveBeenCalledWith( CONTENT_REFERENCE.CONTENT_REF_GET, diff --git a/src/lib/components/ContentReference.ts b/src/lib/components/ContentReference.ts index 909f658..dff36fc 100644 --- a/src/lib/components/ContentReference.ts +++ b/src/lib/components/ContentReference.ts @@ -41,9 +41,16 @@ export class ContentReference { */ getMultiple( contentTypeIds: Array, - options: ContentReferenceOptions = { max: null, pointer: '' } + options: ContentReferenceOptions, ): Promise { - return this.fetchReferences(contentTypeIds, options.pointer, options.max); + const defaultOptions = { + max: null + } + const mergedOptions = { + ...defaultOptions, + ...options + } + return this.fetchReferences(contentTypeIds, mergedOptions.pointer, mergedOptions.max); } /** * This method will trigger a content browser. It returns a promise that will resolve to the chosen Content Reference.