gatsby-core-theme 24.0.2 → 24.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [24.0.3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v24.0.2...v24.0.3) (2023-07-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * make test for content ([c943167](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c943167615cb964d6edd5a5732b9c54c2df7be44))
7
+ * validate if h2 isn't empty ([2b42f4b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2b42f4b83c93a15471191cd3464f1c06488eddec))
8
+
9
+
10
+ * Merge branch 'fix-bug-placheloder' into 'master' ([5346c7b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5346c7b20a2163aa8b7f144c486ea168b4cb4d97))
11
+
1
12
  ## [24.0.2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v24.0.1...v24.0.2) (2023-07-04)
2
13
 
3
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "24.0.2",
3
+ "version": "24.0.3",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -1,10 +1,31 @@
1
1
  import React from 'react';
2
- import { render, cleanup, fireEvent } from '@testing-library/react';
2
+ import { render, cleanup, fireEvent, screen } from '@testing-library/react';
3
+ import { generatePlaceholderString } from '../../../helpers/generators';
3
4
  import '@testing-library/jest-dom/extend-expect';
4
5
  import { getSingleContentData } from '~tests/factories/modules/content.factory';
5
6
  import Content from '.';
6
7
 
7
8
  describe('Content Component', () => {
9
+ const page = {
10
+ siteInfo: {
11
+ site_name: 'My Site',
12
+ },
13
+ title: 'My Page',
14
+ relation: {
15
+ name: 'Page Relation',
16
+ },
17
+ };
18
+
19
+ const module = {
20
+ anchor_label: 'Anchor',
21
+ name: 'Module Name',
22
+ module_title: 'Module Title',
23
+ value: '<h2>[YEAR]</h2>',
24
+ style: 'default',
25
+ show_more_content: '<p>More content</p>',
26
+ show_more_enabled: '1',
27
+ };
28
+
8
29
  test('render content props', () => {
9
30
  const correctData = getSingleContentData('h4');
10
31
  const { container } = render(<Content module={correctData} />);
@@ -200,6 +221,17 @@ describe('Content Component', () => {
200
221
 
201
222
  expect(getByText('More COntent test')).toBeTruthy();
202
223
  });
224
+
225
+ test('renders content with placeholder string for h2', () => {
226
+ const { container } = render(<Content module={module} page={page} />);
227
+ expect(container.querySelector('h2')).toHaveTextContent('2023');
228
+ });
229
+
230
+ test('renders content without placeholder string for h2', () => {
231
+ module.value = '<h2></h2>';
232
+ const { container } = render(<Content module={module} page={page} />);
233
+ expect(container.querySelector('h2')).toHaveTextContent('');
234
+ });
203
235
  });
204
236
  afterEach(() => {
205
237
  cleanup();
@@ -63,7 +63,13 @@ const Content = ({ module, isHomepageFirstModule = false, isModuleIntroduction =
63
63
  pageTitle: page?.title,
64
64
  name: page?.relation?.name,
65
65
  };
66
- node.children[0].data = generatePlaceholderString(node.children[0].data, translations, data);
66
+ // check if h2 is empty
67
+ if (node?.children[0]?.data !== undefined)
68
+ node.children[0].data = generatePlaceholderString(
69
+ node.children[0].data,
70
+ translations,
71
+ data
72
+ );
67
73
  }
68
74
 
69
75
  return null;