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!

remove jest test

Maksim Mrug76a5a3c1ee2f
diff --git a/app/components/__test__/Footer.test.tsx b/app/components/__test__/Footer.test.tsx
deleted file mode 100644
index 2acc368c9..000000000
--- a/app/components/__test__/Footer.test.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-/* 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(
- // @ts-ignore
- <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(
- // @ts-ignore
- <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')
- })
-})
diff --git a/app/components/__test__/Header.test.tsx b/app/components/__test__/Header.test.tsx
deleted file mode 100644
index 697e68881..000000000
--- a/app/components/__test__/Header.test.tsx
+++ /dev/null
@@ -1,107 +0,0 @@
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render, screen } from '@testing-library/react'
-import { I18nextProvider } from 'react-i18next'
-import i18n from 'i18next'
-import { IUser } from 'redux/models/IUser'
-import { createMemoryHistory } from 'history'
-import { Router } from 'react-router-dom'
-import configureMockStore from 'redux-mock-store'
-
-import { Provider } from 'react-redux'
-import Header from '../Header'
-
-describe('Header', () => {
- const history = createMemoryHistory()
- const authenticated = true
- const mockStore = configureMockStore()
- const store = mockStore({})
- const theme = 'dark'
- const user: IUser = {
- id: 'testid',
- email: '[email protected]',
- nickname: 'testuser',
- roles: ['admin'],
- isActive: true,
- planCode: 'testplan',
- trialEndDate: '2021-01-01T00:00:00.000Z',
- reportFrequency: 'daily',
- emailRequests: 0,
- evWarningSentOn: null,
- subID: null,
- subUpdateURL: null,
- subCancelURL: null,
- created: '',
- updated: '',
- exportedAt: '',
- timezone: '',
- theme: null,
- isTwoFactorAuthenticationEnabled: false,
- trialReminderSent: false,
- billingFrequency: null,
- nextBillDate: null,
- cancellationEffectiveDate: null,
- apiKey: null,
- telegramChatId: null,
- isTelegramChatIdConfirmed: false,
- timeFormat: '',
- sharedProjects: [],
- registeredWithGoogle: false,
- googleId: null,
- githubId: null,
- registeredWithGithub: false,
- tierCurrency: 'USD',
- maxEventsCount: 5000000,
- showLiveVisitorsInTitle: false,
- }
-
- beforeEach(() => {
- jest.clearAllMocks()
- })
-
- beforeAll(() => {
- i18n.init({
- lng: 'en',
- fallbackLng: 'en',
- resources: {
- en: {
- 'footer.contact': 'Contact Us',
- 'footer.blog': 'Blog',
- 'common.logout': 'Logout',
- 'common.login': 'Login',
- 'common.dashboard': 'Dashboard',
- },
- },
- })
- })
-
- test('renders authed header if authenticated', () => {
- render(
- // @ts-ignore
- <Router history={history}>
- <Provider store={store}>
- <I18nextProvider i18n={i18n}>
- <Header authenticated={authenticated} theme={theme} user={user} />
- </I18nextProvider>
- </Provider>
- </Router>,
- )
-
- expect(screen.getAllByText(/common.dashboard/i)).toHaveLength(2)
- })
-
- test('renders not-authed header if not authenticated', () => {
- render(
- // @ts-ignore
- <Router history={history}>
- <Provider store={store}>
- <I18nextProvider i18n={i18n}>
- <Header authenticated={false} theme={theme} user={user} />
- </I18nextProvider>
- </Provider>
- </Router>,
- )
-
- expect(screen.getByText(/auth.common.signin/i)).toBeInTheDocument()
- })
-})
diff --git a/app/ui/__test__/Alert.test.tsx b/app/ui/__test__/Alert.test.tsx
deleted file mode 100644
index 8c742f908..000000000
--- a/app/ui/__test__/Alert.test.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render, fireEvent } from '@testing-library/react'
-import AlertTemplate from '../Alert'
-import '@testing-library/jest-dom'
-
-describe('AlertTemplate', () => {
- const closeMock = jest.fn()
-
- afterEach(() => {
- closeMock.mockClear()
- })
-
- test('renders an info alert', () => {
- const { getByText, getByRole } = render(
- <AlertTemplate message='This is an info alert' options={{ type: 'info' }} close={closeMock} />,
- )
-
- expect(getByText('This is an info alert')).toBeInTheDocument()
- expect(getByRole('button')).toBeInTheDocument()
-
- fireEvent.click(getByRole('button'))
- expect(closeMock).toHaveBeenCalled()
- })
-
- test('renders a success alert', () => {
- const { getByText, getByRole } = render(
- <AlertTemplate message='This is a success alert' options={{ type: 'success' }} close={closeMock} />,
- )
-
- expect(getByText('This is a success alert')).toBeInTheDocument()
- expect(getByRole('button')).toBeInTheDocument()
-
- fireEvent.click(getByRole('button'))
- expect(closeMock).toHaveBeenCalled()
- })
-
- test('renders an error alert', () => {
- const { getByText, getByRole } = render(
- <AlertTemplate message='This is an error alert' options={{ type: 'error' }} close={closeMock} />,
- )
-
- expect(getByText('This is an error alert')).toBeInTheDocument()
- expect(getByRole('button')).toBeInTheDocument()
-
- fireEvent.click(getByRole('button'))
- expect(closeMock).toHaveBeenCalled()
- })
-})
diff --git a/app/ui/__test__/Beta.test.tsx b/app/ui/__test__/Beta.test.tsx
deleted file mode 100644
index b9f6b030f..000000000
--- a/app/ui/__test__/Beta.test.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render } from '@testing-library/react'
-import { I18nextProvider } from 'react-i18next'
-import i18n from 'i18next'
-import Beta from '../Beta'
-
-describe('Beta component', () => {
- beforeEach(() => {
- i18n.init({
- lng: 'en',
- resources: {
- en: {
- beta: {
- title: 'beta.title',
- },
- },
- },
- })
- })
-
- it('should render with a custom class name', () => {
- const { getByText } = render(
- <I18nextProvider i18n={i18n}>
- <Beta className='custom-class-name' />
- </I18nextProvider>,
- )
- expect(getByText('beta.title')).toHaveClass('custom-class-name')
- })
-})
diff --git a/app/ui/__test__/Button.test.tsx b/app/ui/__test__/Button.test.tsx
deleted file mode 100644
index d42343a72..000000000
--- a/app/ui/__test__/Button.test.tsx
+++ /dev/null
@@ -1,90 +0,0 @@
-/* eslint-disable import/no-extraneous-dependencies */
-/* eslint-disable testing-library/prefer-screen-queries */
-import React from 'react'
-import { render, fireEvent } from '@testing-library/react'
-import Button from '../Button'
-
-describe('Button component', () => {
- it('renders with text', () => {
- const { getByText } = render(<Button text='Click me' />)
- expect(getByText('Click me')).toBeInTheDocument()
- })
-
- it('renders with children', () => {
- const { getByText } = render(<Button><span>Click me</span></Button>)
- expect(getByText('Click me')).toBeInTheDocument()
- })
-
- it('handles clicks', () => {
- const onClick = jest.fn()
- const { getByRole } = render(<Button onClick={onClick} />)
- fireEvent.click(getByRole('button'))
- expect(onClick).toHaveBeenCalledTimes(1)
- })
-
- it('renders a primary button', () => {
- const { getByText } = render(<Button text='Click me' primary />)
- const button = getByText('Click me')
- expect(button).toHaveClass('bg-indigo-600')
- })
-
- it('renders a secondary button', () => {
- const { getByText } = render(<Button text='Click me' secondary />)
- const button = getByText('Click me')
- expect(button).toHaveClass('bg-indigo-100')
- })
-
- it('renders a white button', () => {
- const { getByText } = render(<Button text='Click me' white />)
- const button = getByText('Click me')
- expect(button).toHaveClass('bg-white')
- })
-
- it('renders a danger button', () => {
- const { getByText } = render(<Button text='Click me' danger />)
- const button = getByText('Click me')
- expect(button).toHaveClass('bg-red-500')
- })
-
- it('renders a semi-danger button', () => {
- const { getByText } = render(<Button text='Click me' semiDanger />)
- const button = getByText('Click me')
- expect(button).toHaveClass('border-red-600')
- })
-
- it('renders a small button', () => {
- const { getByText } = render(<Button text='Click me' small />)
- const button = getByText('Click me')
- expect(button).toHaveClass('text-xs')
- })
-
- it('renders a semi-small button', () => {
- const { getByText } = render(<Button text='Click me' semiSmall />)
- const button = getByText('Click me')
- expect(button).toHaveClass('text-sm')
- })
-
- it('renders a regular button', () => {
- const { getByText } = render(<Button text='Click me' regular />)
- const button = getByText('Click me')
- expect(button).toHaveClass('text-sm')
- })
-
- it('renders a large button', () => {
- const { getByText } = render(<Button text='Click me' large />)
- const button = getByText('Click me')
- expect(button).toHaveClass('text-sm')
- })
-
- it('renders a giant button', () => {
- const { getByText } = render(<Button text='Click me' giant />)
- const button = getByText('Click me')
- expect(button).toHaveClass('text-base')
- })
-
- it('renders a button with no border', () => {
- const { getByText } = render(<Button text='Click me' noBorder />)
- const button = getByText('Click me')
- expect(button).toHaveClass('border-none')
- })
-})
diff --git a/app/ui/__test__/Checkbox.test.tsx b/app/ui/__test__/Checkbox.test.tsx
deleted file mode 100644
index 4297e61db..000000000
--- a/app/ui/__test__/Checkbox.test.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render, fireEvent } from '@testing-library/react'
-import Checkbox from '../Checkbox'
-
-describe('Checkbox', () => {
- test('renders a checkbox', () => {
- const { getByText } = render(<Checkbox label='Checkbox' checked />)
- expect(getByText('Checkbox')).toBeInTheDocument()
- })
-
- test('renders a checkbox with a custom id', () => {
- const { getByRole } = render(
- <Checkbox id='custom-id' label='Checkbox' checked />,
- )
- expect(getByRole('checkbox')).toHaveAttribute('id', 'custom-id')
- })
-
- test('clicking the checkbox calls the onChange handler', () => {
- const onChange = jest.fn()
- const { getByRole } = render(
- <Checkbox label='Checkbox' checked onChange={onChange} />,
- )
- fireEvent.click(getByRole('checkbox'))
- expect(onChange).toHaveBeenCalled()
- })
-})
diff --git a/app/ui/__test__/Dropdown.test.tsx b/app/ui/__test__/Dropdown.test.tsx
deleted file mode 100644
index 1f14f5cf0..000000000
--- a/app/ui/__test__/Dropdown.test.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render, fireEvent } from '@testing-library/react'
-import Dropdown from '../Dropdown'
-
-describe('Dropdown', () => {
- const items = ['Item 1', 'Item 2', 'Item 3']
- const onSelect = jest.fn()
- const defaultProps = {
- title: 'Dropdown Title',
- onSelect,
- items,
- }
-
- afterEach(() => {
- jest.resetAllMocks()
- })
-
- it('should render without errors', () => {
- const { getByText } = render(<Dropdown {...defaultProps} />)
- expect(getByText(defaultProps.title)).toBeInTheDocument()
- })
-
- it('should render the description when provided', () => {
- const description = 'Dropdown description'
- const { getByText } = render(<Dropdown {...defaultProps} desc={description} />)
- expect(getByText(description)).toBeInTheDocument()
- })
-
- it('should call onSelect when an item is clicked', () => {
- const { getByText } = render(<Dropdown {...defaultProps} />)
- const btnOpen = getByText(defaultProps.title)
- fireEvent.click(btnOpen)
- expect(getByText(items[0])).toBeInTheDocument()
- })
-})
diff --git a/app/ui/__test__/Flatpicker.test.tsx b/app/ui/__test__/Flatpicker.test.tsx
deleted file mode 100644
index 5eca18ed2..000000000
--- a/app/ui/__test__/Flatpicker.test.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render } from '@testing-library/react'
-import Flatpicker from '../Flatpicker'
-
-describe('Flatpicker', () => {
- test('renders a flatpicker', () => {
- const { getByTestId } = render(<Flatpicker />)
- expect(getByTestId('calendar')).toBeInTheDocument()
- })
-})
diff --git a/app/ui/__test__/Input.test.tsx b/app/ui/__test__/Input.test.tsx
deleted file mode 100644
index d19c22a74..000000000
--- a/app/ui/__test__/Input.test.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render, fireEvent } from '@testing-library/react'
-import Input from '../Input'
-
-describe('Input component', () => {
- it('renders label, input and hint', () => {
- const { getAllByText, getByText, getByPlaceholderText } = render(
- <Input label='Username' hint='Enter your username' placeholder='Enter your username' />,
- )
- expect(getAllByText(/username/i)).toHaveLength(2)
- expect(getByText(/enter your username/i)).toBeInTheDocument()
- expect(getByPlaceholderText(/enter your username/i)).toBeInTheDocument()
- })
-
- it('calls onChange callback when input value changes', () => {
- const handleChange = jest.fn()
- const { getByRole } = render(<Input label='Username' onChange={handleChange} />)
- const input = getByRole('textbox')
- fireEvent.change(input, { target: { value: 'John' } })
- expect(handleChange).toHaveBeenCalledTimes(1)
- })
-
- it('displays error message when error prop is truthy', () => {
- const { getByRole, getByText } = render(<Input label='Username' error='Username is required' />)
- const input = getByRole('textbox')
- fireEvent.blur(input)
- expect(getByText(/username is required/i)).toBeInTheDocument()
- })
-
- it('disables input when disabled prop is true', () => {
- const { getByRole } = render(<Input label='Username' disabled />)
- const input = getByRole('textbox') as HTMLInputElement
- expect(input).toBeDisabled()
- })
-})
diff --git a/app/ui/__test__/Loader.test.tsx b/app/ui/__test__/Loader.test.tsx
deleted file mode 100644
index 5cae6b806..000000000
--- a/app/ui/__test__/Loader.test.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render } from '@testing-library/react'
-import Loader from '../Loader'
-
-describe('Loader', () => {
- it('renders the loader with the "Loading..." text', () => {
- const { getByText } = render(<Loader />)
- expect(getByText('Loading...')).toBeInTheDocument()
- })
-})
diff --git a/app/ui/__test__/Modal.test.tsx b/app/ui/__test__/Modal.test.tsx
deleted file mode 100644
index 4daa588c4..000000000
--- a/app/ui/__test__/Modal.test.tsx
+++ /dev/null
@@ -1,90 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render, fireEvent } from '@testing-library/react'
-import { I18nextProvider } from 'react-i18next'
-import i18n from 'i18next'
-import Modal from '../Modal'
-
-describe('Modal component', () => {
- const defaultProps: {
- type: 'error' | 'success' | 'info' | 'warning' | 'confirmed',
- title: string,
- message: string,
- isOpened: boolean,
- onClose: () => void,
- } = {
- type: 'success',
- title: 'Success',
- message: 'Action completed successfully',
- isOpened: true,
- onClose: jest.fn(),
- }
-
- // use HOC to wrap component with I18nextProvider
- const HocWithI18n = (props: any): JSX.Element => (
- <I18nextProvider i18n={i18n}>
- <Modal {...props} />
- </I18nextProvider>
- )
-
- // initialize i18n before each test
- beforeEach(() => {
- i18n.init({
- lng: 'en',
- resources: {
- en: {
- beta: {
- title: 'beta.title',
- },
- },
- },
- })
- })
-
- afterEach(() => {
- jest.resetAllMocks()
- })
-
- it('renders with default props', () => {
- const { getByText } = render(
- <HocWithI18n {...defaultProps} />,
- )
- expect(getByText('Success')).toBeInTheDocument()
- expect(getByText('Action completed successfully')).toBeInTheDocument()
- })
-
- it('calls onClose when close button is clicked', () => {
- const { getByText } = render(
- <HocWithI18n {...defaultProps} closeText='Close' />,
- )
- const closeButton = getByText('Close')
- fireEvent.click(closeButton)
- expect(defaultProps.onClose).toHaveBeenCalled()
- })
-
- it('calls onSubmit when submit button is clicked', () => {
- const onSubmit = jest.fn()
- const { getByText } = render(
- <HocWithI18n {...defaultProps} onSubmit={onSubmit} submitText='Submit' />,
- )
- const submitButton = getByText('Submit')
- fireEvent.click(submitButton)
- expect(onSubmit).toHaveBeenCalled()
- })
-
- it('renders custom buttons', () => {
- const customButtons = <button type='button'>Custom Button</button>
- const { getByText } = render(
- <HocWithI18n {...defaultProps} customButtons={customButtons} />,
- )
- expect(getByText('Custom Button')).toBeInTheDocument()
- })
-
- it('renders beta badge when isBeta prop is true', () => {
- const { getByText } = render(
- <HocWithI18n {...defaultProps} isBeta />,
- )
- expect(getByText('beta.title')).toBeInTheDocument()
- })
-})
diff --git a/app/ui/__test__/Pagination.test.tsx b/app/ui/__test__/Pagination.test.tsx
deleted file mode 100644
index 929eb40b1..000000000
--- a/app/ui/__test__/Pagination.test.tsx
+++ /dev/null
@@ -1,109 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render } from '@testing-library/react'
-import { I18nextProvider } from 'react-i18next'
-import i18n from 'i18next'
-import Pagination from '../Pagination'
-
-describe('Pagination', () => {
- let defaultProps: {
- page: number,
- setPage: (item: number) => void,
- pageAmount: number,
- total: number,
- } = {
- page: 1,
- setPage: () => {
- defaultProps.page += 1
- },
- pageAmount: 10,
- total: 100,
- }
-
- // use HOC to wrap component with I18nextProvider
- const HocWithI18n = (props: any): JSX.Element => (
- <I18nextProvider i18n={i18n}>
- <Pagination {...props} />
- </I18nextProvider>
- )
-
- // initialize i18n before each test
- beforeEach(() => {
- i18n.init({
- lng: 'en',
- resources: {
- en: {
- project: {
- prev: 'project.prev',
- next: 'project.next',
- },
- },
- },
- })
- })
-
- afterEach(() => {
- jest.resetAllMocks()
- defaultProps = {
- page: 1,
- setPage: () => {
- defaultProps.page += 1
- },
- pageAmount: 10,
- total: 100,
- }
- })
-
- it('renders with default props', () => {
- const { getByText } = render(
- <HocWithI18n {...defaultProps} />,
- )
- expect(getByText('1')).toBeInTheDocument()
- expect(getByText('10')).toBeInTheDocument()
- expect(getByText('project.next')).toBeInTheDocument()
- })
-
- it('renders on page > 1', () => {
- defaultProps.page = 2
- const { getByText } = render(
- <HocWithI18n {...defaultProps} />,
- )
- expect(getByText('1')).toBeInTheDocument()
- expect(getByText('10')).toBeInTheDocument()
- expect(getByText('project.prev')).toBeInTheDocument()
- expect(getByText('project.next')).toBeInTheDocument()
- })
-
- it('renders on page > 1 and page < pageAmount', () => {
- defaultProps.page = 5
- const { getByText } = render(
- <HocWithI18n {...defaultProps} />,
- )
- expect(getByText('1')).toBeInTheDocument()
- expect(getByText('10')).toBeInTheDocument()
- expect(getByText('project.prev')).toBeInTheDocument()
- expect(getByText('project.next')).toBeInTheDocument()
- })
-
- it('renders on page = pageAmount', () => {
- defaultProps.page = 10
- const { getByText } = render(
- <HocWithI18n {...defaultProps} />,
- )
- expect(getByText('1')).toBeInTheDocument()
- expect(getByText('10')).toBeInTheDocument()
- expect(getByText('project.prev')).toBeInTheDocument()
- })
-
- it('renders on page = pageAmount and pageAmount < total', () => {
- defaultProps.page = 10
- defaultProps.total = 101
- const { getByText } = render(
- <HocWithI18n {...defaultProps} />,
- )
- expect(getByText('1')).toBeInTheDocument()
- expect(getByText('9')).toBeInTheDocument()
- expect(getByText('project.prev')).toBeInTheDocument()
- })
-})
diff --git a/app/ui/__test__/Pin.test.tsx b/app/ui/__test__/Pin.test.tsx
deleted file mode 100644
index 8a2a26757..000000000
--- a/app/ui/__test__/Pin.test.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render } from '@testing-library/react'
-import {
- WarningPin, ActivePin, InactivePin, CustomPin,
-} from '../Pin'
-
-describe('Pin', () => {
- const defaultProps: {
- label: string,
- className?: string,
- } = {
- label: 'label',
- className: 'className',
- }
-
- it('renders the warning pin', () => {
- const { getByText } = render(<WarningPin {...defaultProps} />)
- expect(getByText('label')).toBeInTheDocument()
- })
-
- it('renders the active pin', () => {
- const { getByText } = render(<ActivePin {...defaultProps} />)
- expect(getByText('label')).toBeInTheDocument()
- })
-
- it('renders the inactive pin', () => {
- const { getByText } = render(<InactivePin {...defaultProps} />)
- expect(getByText('label')).toBeInTheDocument()
- })
-
- it('renders the custom pin', () => {
- const { getByText } = render(<CustomPin {...defaultProps} />)
- expect(getByText('label')).toBeInTheDocument()
- })
-
- it('renders the custom pin with custom className', () => {
- const { getByText } = render(<CustomPin {...defaultProps} className='customClassName' />)
- expect(getByText('label')).toBeInTheDocument()
- })
-})
diff --git a/app/ui/__test__/Progress.test.tsx b/app/ui/__test__/Progress.test.tsx
deleted file mode 100644
index 7354454a3..000000000
--- a/app/ui/__test__/Progress.test.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render } from '@testing-library/react'
-
-import Progress from '../Progress'
-
-describe('Progress', () => {
- it('renders the progress bar', () => {
- const { getByTestId } = render(<Progress now={10} />)
- expect(getByTestId('progress')).toBeInTheDocument()
- })
-})
diff --git a/app/ui/__test__/Select.test.tsx b/app/ui/__test__/Select.test.tsx
deleted file mode 100644
index 80409c605..000000000
--- a/app/ui/__test__/Select.test.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { fireEvent, render } from '@testing-library/react'
-import _forEach from 'lodash/forEach'
-import Select from '../Select'
-
-describe('Select', () => {
- const defaultProps: {
- title: string,
- label: string,
- className?: string,
- items: any[],
- id?: string,
- labelExtractor?: (item: any, index: number) => string,
- keyExtractor?: (item: any, index: number) => string,
- iconExtractor?: (item: any, index: number) => JSX.Element | null,
- onSelect: (item: any) => void,
- } = {
- title: 'Select Title',
- label: 'Select',
- items: [],
- onSelect: () => {},
- }
-
- afterEach(() => {
- jest.resetAllMocks()
- })
-
- it('should render without errors', () => {
- const { getByText } = render(<Select {...defaultProps} />)
- expect(getByText(defaultProps.label)).toBeInTheDocument()
- })
-
- it('should render the title when provided', () => {
- const title = 'Select Title'
- const { getByText } = render(<Select {...defaultProps} title={title} />)
- expect(getByText(title)).toBeInTheDocument()
- })
-
- it('should render the description when provided', () => {
- const description = 'Select description'
- const { getByText } = render(<Select {...defaultProps} label={description} />)
- expect(getByText(description)).toBeInTheDocument()
- })
-
- it('should render the items when provided', () => {
- const items = ['Item 1', 'Item 2', 'Item 3']
- const { getByText } = render(<Select {...defaultProps} items={items} />)
- fireEvent.click(getByText(defaultProps.title))
- _forEach(items, (item) => {
- expect(getByText(item)).toBeInTheDocument()
- })
- })
-})
diff --git a/app/ui/__test__/TimezonePicker.test.tsx b/app/ui/__test__/TimezonePicker.test.tsx
deleted file mode 100644
index b14e9fe3b..000000000
--- a/app/ui/__test__/TimezonePicker.test.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { fireEvent, render } from '@testing-library/react'
-import { I18nextProvider } from 'react-i18next'
-import i18n from 'i18next'
-
-import TimezonePicker from '../TimezonePicker'
-
-describe('TimezonePricker', () => {
- const onChange = jest.fn()
-
- afterEach(() => {
- jest.clearAllMocks()
- })
-
- const HocWithI18n = (props: any): JSX.Element => (
- <I18nextProvider i18n={i18n}>
- <TimezonePicker {...props} />
- </I18nextProvider>
- )
-
- // initialize i18n before each test
- beforeEach(() => {
- i18n.init({
- lng: 'en',
- resources: {
- en: {
- profileSettings: {
- timezoneDesc: 'Timezone description',
- },
- },
- },
- })
- })
-
- afterEach(() => {
- jest.resetAllMocks()
- })
-
- it('renders the component', () => {
- const { getByText } = render(
- <HocWithI18n value='Europe/London' onChange={onChange} />,
- )
-
- expect(getByText('(GMT+1:00) Edinburgh, London')).toBeInTheDocument()
- })
-
- it('calls onChange function when an option is selected', () => {
- const { getByText, getByRole } = render(
- <HocWithI18n value='Europe/London' onChange={onChange} />,
- )
-
- fireEvent.click(getByRole('button'))
-
- const option = getByText('(GMT-7:00) Arizona')
- fireEvent.click(option)
-
- expect(onChange).toHaveBeenCalledTimes(1)
- expect(onChange).toHaveBeenCalledWith('America/Phoenix')
- })
-})
diff --git a/app/ui/__test__/Tooltip.test.tsx b/app/ui/__test__/Tooltip.test.tsx
deleted file mode 100644
index 0cf8b3b2f..000000000
--- a/app/ui/__test__/Tooltip.test.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-/* eslint-disable testing-library/prefer-screen-queries */
-/* eslint-disable import/no-extraneous-dependencies */
-import React from 'react'
-import { render, fireEvent } from '@testing-library/react'
-import Tooltip from '../Tooltip'
-
-describe('Tooltip', () => {
- it('should render the tooltip text when hovering over the icon', () => {
- const text = 'This is a tooltip'
- const { getByTestId, getByText } = render(
- <Tooltip text={text} />,
- )
- const tooltipIcon = getByTestId('tooltip-icon')
- fireEvent.mouseEnter(tooltipIcon)
- const tooltipText = getByText(text)
- expect(tooltipText).toBeInTheDocument()
- })
-
- it('should render a custom tooltip icon when provided', () => {
- const CustomIcon = () => <div data-testid='custom-icon' />
- const { getByTestId } = render(
- <Tooltip tooltipNode={<CustomIcon />} text='dds' />,
- )
- const customIcon = getByTestId('custom-icon')
- expect(customIcon).toBeInTheDocument()
- })
-
- it('should render a custom class name when provided', () => {
- const className = 'custom-class'
- const { getByTestId } = render(
- <Tooltip text='Tooltip' className={className} />,
- )
- const tooltipWrapper = getByTestId('tooltip-wrapper')
- expect(tooltipWrapper).toHaveClass(className)
- })
-})