From 86657461c9ef757b8c3be220dea96f583d4ea5c1 Mon Sep 17 00:00:00 2001 From: thenaim Date: Sun, 24 Apr 2022 16:24:21 +0300 Subject: [PATCH 1/2] feat(): render image file with base href --- .../image/__snapshots__/index.test.tsx.snap | 48 +++++++++++++++++++ src/renderers/image/index.test.tsx | 23 +++++++++ src/renderers/image/index.tsx | 4 +- 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/renderers/image/__snapshots__/index.test.tsx.snap b/src/renderers/image/__snapshots__/index.test.tsx.snap index 044610f..284ce0d 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`] = `
when receives a Image block with actions renders a
b
`; +exports[` when receives a Image block with/without file base href with file base href 1`] = ` +
+ Deep in the universe +
+ Deep in the universe +
+
+`; + +exports[` when receives a Image block with/without file base href without file base href 1`] = ` +
+ Deep in the universe +
+ Deep in the universe +
+
+`; + exports[` when receives a Image block without 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)}
}
From d413c63637deb3c5376ce4d904333a6d4dd894e2 Mon Sep 17 00:00:00 2001 From: thenaim Date: Sun, 24 Apr 2022 16:26:20 +0300 Subject: [PATCH 2/2] fix(): image snapshots --- .../image/__snapshots__/index.test.tsx.snap | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/renderers/image/__snapshots__/index.test.tsx.snap b/src/renderers/image/__snapshots__/index.test.tsx.snap index 284ce0d..38d9a6f 100644 --- a/src/renderers/image/__snapshots__/index.test.tsx.snap +++ b/src/renderers/image/__snapshots__/index.test.tsx.snap @@ -41,30 +41,6 @@ exports[` when receives a Image block with actions renders a
b
`; -exports[` when receives a Image block with/without file base href with file base href 1`] = ` -
- Deep in the universe -
- Deep in the universe -
-
-`; - -exports[` when receives a Image block with/without file base href without file base href 1`] = ` -
- Deep in the universe -
- Deep in the universe -
-
-`; - exports[` when receives a Image block without actions renders a
block with and
1`] = `