From 8ea0b8c00e8890972507ba7cd17c772ebc941079 Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 28 Mar 2022 13:23:43 +0200 Subject: [PATCH] :white_check_mark: Add Test for ReloadInfo --- src/components/ReloadInfo.test.tsx | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/components/ReloadInfo.test.tsx diff --git a/src/components/ReloadInfo.test.tsx b/src/components/ReloadInfo.test.tsx new file mode 100644 index 0000000..98aeb3a --- /dev/null +++ b/src/components/ReloadInfo.test.tsx @@ -0,0 +1,36 @@ +import React from 'react' +import { render, screen } from '@testing-library/react' +import { ReloadInfo } from './index' + +describe('ReloadInfo', function () { + beforeAll(function () { + localStorage.removeItem('showReloadInfo') + }) + + test('renders correctly', function () { + const { container } = render() + + expect( + screen.getByText( + 'The messages update automatically. There is no need to reload the entire page.' + ) + ).toBeVisible() + + const close = container.querySelector('i.close') as HTMLElement + close.click() + + expect(localStorage.getItem('showReloadInfo')).toBe('0') + }) + + test('not renders if dismissed', function () { + localStorage.setItem('showReloadInfo', '0') + const { container } = render() + + expect( + screen.getByText( + 'The messages update automatically. There is no need to reload the entire page.' + ) + ).toBeInTheDocument() + expect(container.firstElementChild).toHaveClass('hidden') + }) +})