From e73e0c5feb2f1afe859563195bb910bf57d71998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Moiti=C3=A9?= Date: Tue, 12 Sep 2023 02:06:04 +0100 Subject: [PATCH] Add missing tests and missing tags from HTML file --- src/components/CoachDaveSponsor.js | 1 + .../__tests__/CoachDaveSponsor.test.js | 28 +++++++++++++++ .../CoachDaveSponsor.test.js.snap | 35 +++++++++++++++++++ src/index.html | 5 ++- 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/components/__tests__/CoachDaveSponsor.test.js create mode 100644 src/components/__tests__/__snapshots__/CoachDaveSponsor.test.js.snap diff --git a/src/components/CoachDaveSponsor.js b/src/components/CoachDaveSponsor.js index 96f18e9..ee93fac 100644 --- a/src/components/CoachDaveSponsor.js +++ b/src/components/CoachDaveSponsor.js @@ -10,6 +10,7 @@ import '@blueprintjs/core/lib/css/blueprint.css'; export default function CoachDaveSponsor(): React.Node { const { t } = useTranslation(); + const clickSponsor = () => { window.dataLayer.push({ event: 'select_content', diff --git a/src/components/__tests__/CoachDaveSponsor.test.js b/src/components/__tests__/CoachDaveSponsor.test.js new file mode 100644 index 0000000..f799309 --- /dev/null +++ b/src/components/__tests__/CoachDaveSponsor.test.js @@ -0,0 +1,28 @@ +import React from 'react'; +import { create, act } from 'react-test-renderer'; +import { describe, test } from '@jest/globals'; +import axios from 'axios'; +import { useTranslation } from 'react-i18next'; + +import CoachDaveSponsor from '../CoachDaveSponsor'; + +jest.mock('react-i18next'); +jest.mock('axios'); + +describe('components/CoachDaveSponsor', () => { + test('renders', async () => { + let component; + + act(() => { + component = create(); + }); + + expect(component.toJSON()).toMatchSnapshot(); + + await act(async () => { + await component.root.findByType('a').props.onClick(); + }); + + expect(window.dataLayer.push).toHaveBeenCalledWith(expect.objectContaining({ event: 'select_content' })); + }); +}); diff --git a/src/components/__tests__/__snapshots__/CoachDaveSponsor.test.js.snap b/src/components/__tests__/__snapshots__/CoachDaveSponsor.test.js.snap new file mode 100644 index 0000000..e01269e --- /dev/null +++ b/src/components/__tests__/__snapshots__/CoachDaveSponsor.test.js.snap @@ -0,0 +1,35 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/CoachDaveSponsor renders 1`] = ` +
+ +

+ Sponsored +

+

+ Looking for iRacing Setups? +

+

+ Grab a setup from Coach Dave Academy, developed by professional sim racers and engineers. +

+

+ Browse Setups +

+
+
+`; diff --git a/src/index.html b/src/index.html index a58cba5..abdd0be 100644 --- a/src/index.html +++ b/src/index.html @@ -1,5 +1,7 @@ + + iRacing Week Planner @@ -21,12 +23,13 @@ +
- + <% for (var chunk in htmlWebpackPlugin.files.chunks) { %>