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) { %>