diff --git a/src/renderers/image/__snapshots__/index.test.tsx.snap b/src/renderers/image/__snapshots__/index.test.tsx.snap index 044610f..38d9a6f 100644 --- a/src/renderers/image/__snapshots__/index.test.tsx.snap +++ b/src/renderers/image/__snapshots__/index.test.tsx.snap @@ -1,5 +1,29 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[` when receives a Image block renders with file base href 1`] = ` +
+ Deep in the universe +
+ Deep in the universe +
+
+`; + +exports[` when receives a Image block renders without file base href 1`] = ` +
+ Deep in the universe +
+ Deep in the universe +
+
+`; + exports[` when receives a Image block with actions renders a
block with and
1`] = `
', () => { expect(create().toJSON()).toMatchSnapshot(); }); }); + + + + describe('when receives a Image block', () => { + const data: ImageBlockData = { + file: { + url: '/uploads/2020/08/681-2000x1300-2.jpg', + name: '681-2000x1300-2', + }, + caption: 'Deep in the universe', + withBorder: false, + stretched: false, + withBackground: false, + }; + + it('renders with file base href', () => { + expect(create().toJSON()).toMatchSnapshot(); + }); + + it('renders without file base href', () => { + expect(create().toJSON()).toMatchSnapshot(); + }); + }); }); diff --git a/src/renderers/image/index.tsx b/src/renderers/image/index.tsx index c691af5..1d7b2b6 100644 --- a/src/renderers/image/index.tsx +++ b/src/renderers/image/index.tsx @@ -16,6 +16,7 @@ export interface ImageBlockData { } export interface ImageBlockConfig { + fileBaseHref?: string; actionsClassNames?: { [s: string]: string; }; @@ -23,6 +24,7 @@ export interface ImageBlockConfig { const Image: RenderFn = ({ data, + fileBaseHref = null, className = '', actionsClassNames = { stretched: 'image-block--stretched', @@ -50,7 +52,7 @@ const Image: RenderFn = ({ return (
- {data?.file?.url && {data.caption} + {data?.file?.url && {data.caption} {data?.url && {data.caption}} {data?.caption &&
{HTMLReactParser(data.caption)}
}