diff --git a/src/__snapshots__/index.test.tsx.snap b/src/__snapshots__/index.test.tsx.snap index 10edee7..720dc9b 100644 --- a/src/__snapshots__/index.test.tsx.snap +++ b/src/__snapshots__/index.test.tsx.snap @@ -182,13 +182,13 @@ Array [ - Name + Total - Qtd + 16 pcs - Price + $450 diff --git a/src/renderers/table/__snapshots__/index.test.tsx.snap b/src/renderers/table/__snapshots__/index.test.tsx.snap index f446587..b13e6cd 100644 --- a/src/renderers/table/__snapshots__/index.test.tsx.snap +++ b/src/renderers/table/__snapshots__/index.test.tsx.snap @@ -1,5 +1,45 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[` when receives a simple table renders a
tag without , or
1`] = ` + + + + + + + + + + + + + + + + + + +
+ Kine + + 1 pcs + + 100$ +
+ Pigs + + 3 pcs + + 200$ +
+ Chickens + + 12 pcs + + 150$ +
+`; + exports[` when receives a table block renders a
tag 1`] = `
@@ -54,6 +94,27 @@ exports[` when receives a table block renders a
tag 1`] = ` + + + + + + +
+ Total + + 16 pcs + + $450 +
+`; + +exports[` when receives a table block without footer renders a
tag without 1`] = ` +
+ +
+ The stock on our store. +
Name @@ -65,6 +126,41 @@ exports[` when receives a table block renders a
tag 1`] = ` Price - + + + + + + + + + + + + + + + + + +
+ Kine + + 1 pcs + + 100$ +
+ Pigs + + 3 pcs + + 200$ +
+ Chickens + + 12 pcs + + 150$ +
`; diff --git a/src/renderers/table/index.test.tsx b/src/renderers/table/index.test.tsx index ddb6c27..201ca59 100644 --- a/src/renderers/table/index.test.tsx +++ b/src/renderers/table/index.test.tsx @@ -19,4 +19,34 @@ describe('', () => { expect(create(
).toJSON()).toMatchSnapshot(); }); }); + + describe('when receives a table block without footer', () => { + const data: TableBlockData = { + header: ['Name', 'Qtd', 'Price'], + content: [ + ['Kine', '1 pcs', '100$'], + ['Pigs', '3 pcs', '200$'], + ['Chickens', '12 pcs', '150$'], + ], + caption: 'The stock on our store.', + }; + + it('renders a
tag without ', () => { + expect(create(
).toJSON()).toMatchSnapshot(); + }); + }); + + describe('when receives a simple table', () => { + const data: TableBlockData = { + content: [ + ['Kine', '1 pcs', '100$'], + ['Pigs', '3 pcs', '200$'], + ['Chickens', '12 pcs', '150$'], + ], + }; + + it('renders a
tag without , or
', () => { + expect(create().toJSON()).toMatchSnapshot(); + }); + }); }); diff --git a/src/renderers/table/index.tsx b/src/renderers/table/index.tsx index 4165299..5482ab3 100644 --- a/src/renderers/table/index.tsx +++ b/src/renderers/table/index.tsx @@ -40,10 +40,10 @@ const Table: RenderFn = ({ data, className = '' }) => { ))} - {data?.header && ( + {data?.footer && ( - {data.header.map((cell, i) => ( + {data?.footer.map((cell, i) => ( ))}
{HTMLReactParser(cell)}