Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

add test for footer

kruzhambus49d7a061190f
diff --git a/package.json b/package.json
index 97a5f3fd2..d160319a1 100644
--- a/package.json
+++ b/package.json
@@ -203,6 +203,7 @@
"eslint-plugin-lodash": "^7.4.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
+ "history": "^5.3.0",
"jest": "^27.5.1",
"postcss": "^8.4.21",
"react-test-renderer": "^18.2.0",
diff --git a/src/components/__test__/Footer.test.tsx b/src/components/__test__/Footer.test.tsx
new file mode 100644
index 000000000..83da63054
--- /dev/null
+++ b/src/components/__test__/Footer.test.tsx
@@ -0,0 +1,97 @@
+/* eslint-disable import/no-extraneous-dependencies */
+/* eslint-disable testing-library/prefer-screen-queries */
+/* eslint-disable import/no-unresolved */
+import React from 'react'
+import { render } from '@testing-library/react'
+import { I18nextProvider } from 'react-i18next'
+import { createMemoryHistory } from 'history'
+import { Router } from 'react-router-dom'
+import i18n from 'i18next'
+import Footer from '../Footer'
+
+describe('Footer', () => {
+ const history = createMemoryHistory()
+
+ const minimalProps = {
+ minimal: true,
+ authenticated: false,
+ }
+
+ const fullProps = {
+ minimal: false,
+ authenticated: true,
+ }
+
+ beforeAll(() => {
+ i18n.init({
+ lng: 'en',
+ fallbackLng: 'en',
+ resources: {
+ en: {
+ common: {
+ 'footer.contact': 'Contact Us',
+ 'footer.pp': 'Privacy Policy',
+ 'footer.tos': 'Terms of Service',
+ 'footer.about': 'About Us',
+ 'footer.status': 'Status',
+ 'footer.slogan': 'Your website, our analytics',
+ 'footer.description': 'Swetrix helps you monitor, analyze and optimize your website traffic in real time',
+ 'footer.madeIn': 'Made in',
+ 'footer.ukraine': 'Ukraine',
+ 'footer.hostedIn': 'Hosted in',
+ 'footer.eu': 'European Union',
+ 'footer.comparisons': 'Comparisons',
+ },
+ },
+ },
+ })
+ })
+
+ it('renders minimal footer', () => {
+ const { getByLabelText, getByText } = render(
+ <Router history={history}>
+ <I18nextProvider i18n={i18n}>
+ <Footer {...minimalProps} />
+ </I18nextProvider>
+ </Router>,
+ )
+
+ expect(getByLabelText('Footer')).toBeInTheDocument()
+
+ expect(getByText('Contact Us')).toHaveAttribute('href', '/contact')
+ expect(getByText('Privacy Policy')).toHaveAttribute('href', '/privacy')
+ expect(getByText('Terms of Service')).toHaveAttribute('href', '/terms')
+ expect(getByText('About Us')).toHaveAttribute('href', '/about')
+ })
+
+ it('renders full footer', () => {
+ const { getByLabelText, getByText } = render(
+ <Router history={history}>
+ <I18nextProvider i18n={i18n}>
+ <Footer {...fullProps} />
+ </I18nextProvider>
+ </Router>,
+ )
+
+ expect(getByLabelText('Footer')).toBeInTheDocument()
+
+ expect(getByText('Contact Us')).toHaveAttribute('href', '/contact')
+ expect(getByText('About Us')).toHaveAttribute('href', '/about')
+ expect(getByText('Made in')).toBeInTheDocument()
+ expect(getByText('Ukraine')).toHaveAttribute('href', 'https://en.wikipedia.org/wiki/Ukraine')
+ expect(getByText('Hosted in')).toBeInTheDocument()
+ expect(getByText('European Union')).toHaveAttribute('href', 'https://en.wikipedia.org/wiki/European_Union')
+ })
+
+ it('snapshot minimal footer', () => {
+ const { container } = render(
+ <Router history={history}>
+ <I18nextProvider i18n={i18n}>
+ <Footer {...minimalProps} />
+ </I18nextProvider>
+ </Router>,
+ )
+
+ expect(container).toMatchSnapshot()
+ })
+})
diff --git a/src/components/__test__/__snapshots__/Footer.test.tsx.snap b/src/components/__test__/__snapshots__/Footer.test.tsx.snap
new file mode 100644
index 000000000..c6c67c086
--- /dev/null
+++ b/src/components/__test__/__snapshots__/Footer.test.tsx.snap
@@ -0,0 +1,72 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Footer snapshot minimal footer 1`] = `
+<div>
+ <footer
+ class="bg-gray-800 dark:bg-gray-900"
+ >
+ <div
+ class="max-w-7xl mx-auto py-8 px-4 overflow-hidden sm:px-6 lg:px-8"
+ >
+ <nav
+ aria-label="Footer"
+ class="-mx-5 -my-2 flex flex-wrap justify-center"
+ >
+ <div
+ class="px-5 py-2"
+ >
+ <a
+ class="text-base text-gray-300 hover:text-white"
+ href="/contact"
+ >
+ Contact Us
+ </a>
+ </div>
+ <div
+ class="px-5 py-2"
+ >
+ <a
+ class="text-base text-gray-300 hover:text-white"
+ href="/privacy"
+ >
+ Privacy Policy
+ </a>
+ </div>
+ <div
+ class="px-5 py-2"
+ >
+ <a
+ class="text-base text-gray-300 hover:text-white"
+ href="/terms"
+ >
+ Terms of Service
+ </a>
+ </div>
+ <div
+ class="px-5 py-2"
+ >
+ <a
+ class="text-base text-gray-300 hover:text-white"
+ href="/about"
+ >
+ About Us
+ </a>
+ </div>
+ <div
+ class="px-5 py-2"
+ >
+ <a
+ aria-label="Status (opens in a new tab)"
+ class="text-base text-gray-300 hover:text-white"
+ href="https://stats.uptimerobot.com/33rvmiXXEz"
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ Status
+ </a>
+ </div>
+ </nav>
+ </div>
+ </footer>
+</div>
+`;
diff --git a/src/ui/__test__/__snapshots__/Chart.test.tsx.snap b/src/ui/__test__/__snapshots__/Chart.test.tsx.snap
index 17d20281b..2fee60800 100644
--- a/src/ui/__test__/__snapshots__/Chart.test.tsx.snap
+++ b/src/ui/__test__/__snapshots__/Chart.test.tsx.snap
@@ -16,7 +16,7 @@ exports[`Chart component snapshot 1`] = `
>
<defs>
<clippath
- id="bb-8491962675112450-clip"
+ id="bb-6964509615290046-clip"
>
<rect
height="226"
@@ -24,7 +24,7 @@ exports[`Chart component snapshot 1`] = `
/>
</clippath>
<clippath
- id="bb-8491962675112450-clip-xaxis"
+ id="bb-6964509615290046-clip-xaxis"
>
<rect
height="110"
@@ -34,7 +34,7 @@ exports[`Chart component snapshot 1`] = `
/>
</clippath>
<clippath
- id="bb-8491962675112450-clip-yaxis"
+ id="bb-6964509615290046-clip-yaxis"
>
<rect
height="240"
@@ -44,7 +44,7 @@ exports[`Chart component snapshot 1`] = `
/>
</clippath>
<clippath
- id="bb-8491962675112450-clip-grid"
+ id="bb-6964509615290046-clip-grid"
>
<rect
height="226"
@@ -58,7 +58,7 @@ exports[`Chart component snapshot 1`] = `
>
<g
class="bb-grid"
- clip-path="url(http://localhost/#bb-8491962675112450-clip-grid)"
+ clip-path="url(http://localhost/#bb-6964509615290046-clip-grid)"
>
<g
class="bb-xgrid-focus"
@@ -74,7 +74,7 @@ exports[`Chart component snapshot 1`] = `
</g>
<g
class="bb-chart"
- clip-path="url(http://localhost/#bb-8491962675112450-clip)"
+ clip-path="url(http://localhost/#bb-6964509615290046-clip)"
>
<g
class="bb-event-rects bb-event-rects-single"
@@ -215,7 +215,7 @@ exports[`Chart component snapshot 1`] = `
</g>
<g
class="bb-axis bb-axis-x"
- clip-path="url(http://localhost/#bb-8491962675112450-clip-xaxis)"
+ clip-path="url(http://localhost/#bb-6964509615290046-clip-xaxis)"
transform="translate(0, 226)"
>
<text
@@ -370,7 +370,7 @@ exports[`Chart component snapshot 1`] = `
</g>
<g
class="bb-axis bb-axis-y"
- clip-path="url(http://localhost/#bb-8491962675112450-clip-yaxis)"
+ clip-path="url(http://localhost/#bb-6964509615290046-clip-yaxis)"
transform="translate(0, 0)"
>
<text
diff --git a/src/ui/__test__/__snapshots__/Flatpicker.test.tsx.snap b/src/ui/__test__/__snapshots__/Flatpicker.test.tsx.snap
index 1a905fa7e..46cbf5783 100644
--- a/src/ui/__test__/__snapshots__/Flatpicker.test.tsx.snap
+++ b/src/ui/__test__/__snapshots__/Flatpicker.test.tsx.snap
@@ -323,28 +323,31 @@ exports[`Flatpicker snapshot 1`] = `
14
</span>
<span
- aria-current="date"
aria-label="April 15, 2023"
- class="flatpickr-day today"
+ class="flatpickr-day"
tabindex="-1"
>
15
</span>
<span
aria-label="April 16, 2023"
- class="flatpickr-day flatpickr-disabled"
+ class="flatpickr-day"
+ tabindex="-1"
>
16
</span>
<span
aria-label="April 17, 2023"
- class="flatpickr-day flatpickr-disabled"
+ class="flatpickr-day"
+ tabindex="-1"
>
17
</span>
<span
+ aria-current="date"
aria-label="April 18, 2023"
- class="flatpickr-day flatpickr-disabled"
+ class="flatpickr-day today"
+ tabindex="-1"
>
18
</span>