Skip to content

Commit

Permalink
Add missing tests and missing tags from HTML file
Browse files Browse the repository at this point in the history
  • Loading branch information
tmoitie committed Sep 12, 2023
1 parent ac1bcef commit e73e0c5
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/CoachDaveSponsor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
28 changes: 28 additions & 0 deletions src/components/__tests__/CoachDaveSponsor.test.js
Original file line number Diff line number Diff line change
@@ -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(<CoachDaveSponsor />);
});

expect(component.toJSON()).toMatchSnapshot();

await act(async () => {
await component.root.findByType('a').props.onClick();
});

expect(window.dataLayer.push).toHaveBeenCalledWith(expect.objectContaining({ event: 'select_content' }));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`components/CoachDaveSponsor renders 1`] = `
<div
className="sponsoredContainer"
>
<a
className="sponsoredLink"
href="https://coachdaveacademy.com/product/iracing-setup-subscription/?ref=weekly_planner"
onClick={[Function]}
rel="sponsored"
>
<h4
className="sponsoredHeader"
>
Sponsored
</h4>
<h3
className="sponsoredTitle"
>
Looking for iRacing Setups?
</h3>
<p
className="sponsoredBody"
>
Grab a setup from Coach Dave Academy, developed by professional sim racers and engineers.
</p>
<p
className="btn btn-primary button"
>
Browse Setups
</p>
</a>
</div>
`;
5 changes: 4 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>iRacing Week Planner</title>
<link rel="apple-touch-icon" sizes="57x57" href="/static/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/static/apple-touch-icon-60x60.png">
Expand All @@ -21,12 +23,13 @@
<meta name="msapplication-TileImage" content="/static/mstile-144x144.png">
<meta name="theme-color" content="#ec232c">
<meta name=viewport content="width=device-width, initial-scale=1">
<meta name="description" content="iRacing Week Planner is a browser app to see and plan your week's racing on iRacing.com" />
<link href="https://fonts.googleapis.com/css?family=Noto+Sans&subset=latin,latin-ext" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Noto+Sans+JP:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<div id='root' class='padbox'></div>
<noscript>Sorry, looks like you don't have JavaScript turned on. We kinda need it!</noscript>
<noscript>JavaScript must be enabled to use this app. Apologies</noscript>

<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
Expand Down

0 comments on commit e73e0c5

Please sign in to comment.