chore: remove jest -> cypress for unit tests
This commit is contained in:
@ -3,10 +3,10 @@ import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import { CogIcon } from '@heroicons/react/solid'
|
||||
|
||||
import { GuildsChannelsPath } from '../../Application'
|
||||
import { Channel as ChannelType } from '../../../../models/Channel'
|
||||
import { useGuildMember } from '../../../../contexts/GuildMember'
|
||||
import { IconButton } from '../../../design/IconButton'
|
||||
import { GuildsChannelsPath } from '../Application'
|
||||
import { Channel as ChannelType } from '../../../models/Channel'
|
||||
import { useGuildMember } from '../../../contexts/GuildMember'
|
||||
import { IconButton } from '../../design/IconButton'
|
||||
|
||||
export interface ChannelProps {
|
||||
path: GuildsChannelsPath
|
@ -1 +0,0 @@
|
||||
export * from './Channel'
|
@ -1,7 +1,7 @@
|
||||
import Image from 'next/image'
|
||||
|
||||
import { GuildWithDefaultChannelId } from '../../../../models/Guild'
|
||||
import { IconLink } from '../../../design/IconLink'
|
||||
import { GuildWithDefaultChannelId } from '../../../models/Guild'
|
||||
import { IconLink } from '../../design/IconLink'
|
||||
|
||||
export interface GuildProps {
|
||||
guild: GuildWithDefaultChannelId
|
@ -1,18 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { Guild } from './Guild'
|
||||
import { guildExample } from '../../../../cypress/fixtures/guilds/guild'
|
||||
|
||||
describe('<Guild />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(
|
||||
<Guild
|
||||
guild={{
|
||||
...guildExample,
|
||||
defaultChannelId: 1
|
||||
}}
|
||||
/>
|
||||
)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -1 +0,0 @@
|
||||
export * from './Guild'
|
@ -5,13 +5,13 @@ import useTranslation from 'next-translate/useTranslation'
|
||||
import classNames from 'classnames'
|
||||
import axios from 'axios'
|
||||
|
||||
import { Emoji } from '../../../Emoji'
|
||||
import { ConfirmPopup } from '../../ConfirmPopup'
|
||||
import { Emoji } from '../../Emoji'
|
||||
import { ConfirmPopup } from '../ConfirmPopup'
|
||||
import {
|
||||
GuildPublic as GuildPublicType,
|
||||
GuildWithDefaultChannelId
|
||||
} from '../../../../models/Guild'
|
||||
import { useAuthentication } from '../../../../tools/authentication'
|
||||
} from '../../../models/Guild'
|
||||
import { useAuthentication } from '../../../tools/authentication'
|
||||
|
||||
export interface GuildPublicProps {
|
||||
guild: GuildPublicType
|
@ -1 +0,0 @@
|
||||
export * from './GuildPublic'
|
@ -1,8 +1,8 @@
|
||||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
|
||||
import { MemberWithPublicUser } from '../../../../models/Member'
|
||||
import { Emoji } from '../../../Emoji'
|
||||
import { MemberWithPublicUser } from '../../../models/Member'
|
||||
import { Emoji } from '../../Emoji'
|
||||
|
||||
export interface MemberProps {
|
||||
member: MemberWithPublicUser
|
@ -1 +0,0 @@
|
||||
export * from './Member'
|
@ -1,10 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { PopupGuild } from './PopupGuild'
|
||||
|
||||
describe('<PopupGuild />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(<PopupGuild />)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -3,7 +3,8 @@ import { PlusSmIcon, ArrowDownIcon } from '@heroicons/react/solid'
|
||||
import classNames from 'classnames'
|
||||
import Image from 'next/image'
|
||||
|
||||
import { PopupGuildCard } from './PopupGuildCard/PopupGuildCard'
|
||||
import { PopupGuildCard } from './PopupGuildCard'
|
||||
|
||||
export interface PopupGuildProps {
|
||||
className?: string
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
import { PlusSmIcon } from '@heroicons/react/solid'
|
||||
import Image from 'next/image'
|
||||
|
||||
import { PopupGuildCard } from './PopupGuildCard'
|
||||
|
||||
describe('<PopupGuildCard />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(
|
||||
<PopupGuildCard
|
||||
image={
|
||||
<Image
|
||||
quality={100}
|
||||
src='/images/svg/design/create-server.svg'
|
||||
alt=''
|
||||
width={230}
|
||||
height={230}
|
||||
/>
|
||||
}
|
||||
description='Create your own guild and manage everything within a few clicks !'
|
||||
link={{
|
||||
icon: <PlusSmIcon className='mr-2 h-8 w-8' />,
|
||||
text: 'Create a server',
|
||||
href: '/application/guilds/create'
|
||||
}}
|
||||
/>
|
||||
)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -1 +0,0 @@
|
||||
export * from './PopupGuildCard'
|
@ -1,12 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { Sidebar } from './Sidebar'
|
||||
|
||||
describe('<Sidebar />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(
|
||||
<Sidebar direction='left' visible={true} isMobile={false} />
|
||||
)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -1,23 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import {
|
||||
guildExample,
|
||||
guildExample2
|
||||
} from '../../../cypress/fixtures/guilds/guild'
|
||||
import {
|
||||
userExample,
|
||||
userSettingsExample
|
||||
} from '../../../cypress/fixtures/users/user'
|
||||
import { UserProfile } from './UserProfile'
|
||||
|
||||
describe('<UserProfile />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(
|
||||
<UserProfile
|
||||
user={{ ...userExample, settings: userSettingsExample }}
|
||||
guilds={[guildExample, guildExample2]}
|
||||
/>
|
||||
)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -1,18 +0,0 @@
|
||||
import { isStringWithOnlyOneEmoji } from './isStringWithOnlyOneEmoji'
|
||||
|
||||
describe('components/Emoji/isStringWithOnlyOneEmoji', () => {
|
||||
it('returns true with a string with only one emoji', () => {
|
||||
expect(isStringWithOnlyOneEmoji(':wave:')).toBeTruthy()
|
||||
expect(isStringWithOnlyOneEmoji(':smile:')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('returns false with a string with multiple emoji or with text', () => {
|
||||
expect(isStringWithOnlyOneEmoji(':wave: :smile:')).toBeFalsy()
|
||||
expect(isStringWithOnlyOneEmoji(':wave: some text')).toBeFalsy()
|
||||
expect(isStringWithOnlyOneEmoji('some text :wave:')).toBeFalsy()
|
||||
})
|
||||
|
||||
it('returns false with a string without emoji', () => {
|
||||
expect(isStringWithOnlyOneEmoji('some text')).toBeFalsy()
|
||||
})
|
||||
})
|
@ -1,15 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { ErrorPage } from '.'
|
||||
|
||||
describe('<ErrorPage />', () => {
|
||||
it('should render the message and statusCode', () => {
|
||||
const messageContent = 'message content'
|
||||
const statusCode = 404
|
||||
const { getByText } = render(
|
||||
<ErrorPage statusCode={statusCode} message={messageContent} />
|
||||
)
|
||||
expect(getByText(messageContent)).toBeInTheDocument()
|
||||
expect(getByText(statusCode)).toBeInTheDocument()
|
||||
})
|
||||
})
|
@ -1 +0,0 @@
|
||||
export * from './ErrorPage'
|
@ -1,16 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { Footer } from '.'
|
||||
|
||||
describe('<Footer />', () => {
|
||||
it('should render with appropriate link tag version', () => {
|
||||
const version = '1.0.0'
|
||||
const { getByText } = render(<Footer version={version} />)
|
||||
const versionLink = getByText(`website v${version}`) as HTMLAnchorElement
|
||||
expect(getByText('Thream')).toBeInTheDocument()
|
||||
expect(versionLink).toBeInTheDocument()
|
||||
expect(versionLink.href).toEqual(
|
||||
`https://github.com/Thream/website/releases/tag/v${version}`
|
||||
)
|
||||
})
|
||||
})
|
@ -8,6 +8,7 @@ export const VersionLink: React.FC<VersionLinkProps> = (props) => {
|
||||
|
||||
return (
|
||||
<a
|
||||
data-cy={`version-link-${repository}`}
|
||||
className='text-green-800 hover:underline dark:text-green-400'
|
||||
href={`https://github.com/Thream/${repository}/releases/tag/v${version}`}
|
||||
target='_blank'
|
||||
|
@ -1,10 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { ScrollableBody } from './ScrollableBody'
|
||||
|
||||
describe('<ScrollableBody />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(<ScrollableBody />)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -1 +0,0 @@
|
||||
export * from './ScrollableBody'
|
@ -1,10 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { Button } from '.'
|
||||
|
||||
describe('<Button />', () => {
|
||||
it('should render', () => {
|
||||
const { getByText } = render(<Button>Submit</Button>)
|
||||
expect(getByText('Submit')).toBeInTheDocument()
|
||||
})
|
||||
})
|
@ -1,10 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { Checkbox } from './Checkbox'
|
||||
|
||||
describe('<Checkbox />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(<Checkbox label='Checkbox' />)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -1,10 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { Divider } from '.'
|
||||
|
||||
describe('<Divider />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(<Divider />)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -1,34 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { FormState } from '.'
|
||||
|
||||
describe('<FormState />', () => {
|
||||
it('should return nothing if the state is idle', () => {
|
||||
const { container } = render(<FormState state='idle' />)
|
||||
expect(container.innerHTML.length).toEqual(0)
|
||||
})
|
||||
|
||||
it('should return nothing if the message is null', () => {
|
||||
const { container } = render(<FormState state='error' />)
|
||||
expect(container.innerHTML.length).toEqual(0)
|
||||
})
|
||||
|
||||
it('should render the <Loader /> if state is loading', () => {
|
||||
const { getByTestId } = render(<FormState state='loading' />)
|
||||
expect(getByTestId('loader')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should render the success message if state is success', () => {
|
||||
const message = 'Success Message'
|
||||
const { getByText } = render(
|
||||
<FormState state='success' message={message} />
|
||||
)
|
||||
expect(getByText(message)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should render the error message if state is error', () => {
|
||||
const message = 'Error Message'
|
||||
const { getByText } = render(<FormState state='error' message={message} />)
|
||||
expect(getByText(message)).toBeInTheDocument()
|
||||
})
|
||||
})
|
@ -16,7 +16,7 @@ export const FormState: React.FC<FormStateProps> = (props) => {
|
||||
|
||||
if (state === 'loading') {
|
||||
return (
|
||||
<div data-testid='loader' className='mt-8 flex justify-center'>
|
||||
<div data-cy='loader' className='mt-8 flex justify-center'>
|
||||
<Loader />
|
||||
</div>
|
||||
)
|
||||
|
@ -1,15 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
import { CogIcon } from '@heroicons/react/solid'
|
||||
|
||||
import { IconButton } from './IconButton'
|
||||
|
||||
describe('<IconButton />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(
|
||||
<IconButton className='h-10 w-10'>
|
||||
<CogIcon />
|
||||
</IconButton>
|
||||
)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -1,10 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { IconLink } from './IconLink'
|
||||
|
||||
describe('<IconLink />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(<IconLink href='' />)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -1,52 +0,0 @@
|
||||
import { render, fireEvent } from '@testing-library/react'
|
||||
|
||||
import { Input, getInputType } from '.'
|
||||
|
||||
describe('<Input />', () => {
|
||||
it('should render the label', () => {
|
||||
const labelContent = 'label content'
|
||||
const { getByText } = render(<Input label={labelContent} />)
|
||||
expect(getByText(labelContent)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should not render forgot password link', () => {
|
||||
const { queryByTestId } = render(
|
||||
<Input type='text' label='content' showForgotPassword />
|
||||
)
|
||||
const forgotPasswordLink = queryByTestId('forgot-password-link')
|
||||
expect(forgotPasswordLink).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should render forgot password link', () => {
|
||||
const { queryByTestId } = render(
|
||||
<Input type='password' label='content' showForgotPassword />
|
||||
)
|
||||
const forgotPasswordLink = queryByTestId('forgot-password-link')
|
||||
expect(forgotPasswordLink).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should not render the eye icon if the input is not of type "password"', () => {
|
||||
const { queryByTestId } = render(<Input type='text' label='content' />)
|
||||
const passwordEye = queryByTestId('password-eye')
|
||||
expect(passwordEye).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should handlePassword with eye icon', async () => {
|
||||
const { findByTestId } = render(<Input type='password' label='content' />)
|
||||
const passwordEye = await findByTestId('password-eye')
|
||||
const input = await findByTestId('input')
|
||||
expect(input).toHaveAttribute('type', 'password')
|
||||
fireEvent.click(passwordEye)
|
||||
expect(input).toHaveAttribute('type', 'text')
|
||||
})
|
||||
})
|
||||
|
||||
describe('getInputType', () => {
|
||||
it('should return `text`', () => {
|
||||
expect(getInputType('password')).toEqual('text')
|
||||
})
|
||||
|
||||
it('should return `password`', () => {
|
||||
expect(getInputType('text')).toEqual('password')
|
||||
})
|
||||
})
|
@ -47,7 +47,7 @@ export const Input: React.FC<InputProps> = (props) => {
|
||||
<Link href='/authentication/forgot-password'>
|
||||
<a
|
||||
className='text-center font-headline text-xs text-green-800 hover:underline dark:text-green-400 sm:text-sm'
|
||||
data-testid='forgot-password-link'
|
||||
data-cy='forgot-password-link'
|
||||
>
|
||||
{t('authentication:forgot-password')}
|
||||
</a>
|
||||
@ -56,7 +56,6 @@ export const Input: React.FC<InputProps> = (props) => {
|
||||
</div>
|
||||
<div className='relative mt-0'>
|
||||
<input
|
||||
data-testid='input'
|
||||
data-cy={`input-${name ?? 'name'}`}
|
||||
className='h-11 w-full rounded-lg border border-transparent bg-[#f1f1f1] px-3 font-paragraph leading-10 text-[#2a2a2a] caret-green-600 focus:border focus:shadow-green focus:outline-none'
|
||||
{...rest}
|
||||
@ -66,7 +65,7 @@ export const Input: React.FC<InputProps> = (props) => {
|
||||
/>
|
||||
{type === 'password' && (
|
||||
<div
|
||||
data-testid='password-eye'
|
||||
data-cy='password-eye'
|
||||
onClick={handlePassword}
|
||||
className='password-eye absolute cursor-pointer bg-[#f1f1f1] bg-cover'
|
||||
/>
|
||||
|
@ -1,20 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { Loader } from '.'
|
||||
|
||||
describe('<Loader />', () => {
|
||||
it('should render with correct width and height', async () => {
|
||||
const size = 20
|
||||
const { findByTestId } = render(<Loader width={size} height={size} />)
|
||||
const progressSpinner = await findByTestId('progress-spinner')
|
||||
expect(progressSpinner).toHaveStyle(`width: ${size}px`)
|
||||
expect(progressSpinner).toHaveStyle(`height: ${size}px`)
|
||||
})
|
||||
|
||||
it('should render with default width and height', async () => {
|
||||
const { findByTestId } = render(<Loader />)
|
||||
const progressSpinner = await findByTestId('progress-spinner')
|
||||
expect(progressSpinner).toHaveStyle('width: 50px')
|
||||
expect(progressSpinner).toHaveStyle('height: 50px')
|
||||
})
|
||||
})
|
@ -9,7 +9,7 @@ export const Loader: React.FC<LoaderProps> = (props) => {
|
||||
|
||||
return (
|
||||
<div className={props.className}>
|
||||
<div data-testid='progress-spinner' className='progress-spinner'>
|
||||
<div data-cy='progress-spinner' className='progress-spinner'>
|
||||
<svg className='progress-spinner-svg' viewBox='25 25 50 50'>
|
||||
<circle
|
||||
className='progress-spinner-circle'
|
||||
|
@ -1,10 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { Main } from '.'
|
||||
|
||||
describe('<Main />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(<Main />)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
@ -1,23 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { SocialMedia, SocialMediaButton } from '.'
|
||||
|
||||
describe('<SocialMediaButton />', () => {
|
||||
it('should render the social media', async () => {
|
||||
const socialMedia: SocialMedia = 'Discord'
|
||||
const { findByAltText } = render(
|
||||
<SocialMediaButton socialMedia={socialMedia} />
|
||||
)
|
||||
const socialMediaButton = await findByAltText(socialMedia)
|
||||
expect(socialMediaButton).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should render with a black text color with Google social media', async () => {
|
||||
const socialMedia: SocialMedia = 'Google'
|
||||
const { findByTestId } = render(
|
||||
<SocialMediaButton socialMedia={socialMedia} />
|
||||
)
|
||||
const button = await findByTestId('social-media-button')
|
||||
expect(button).toHaveStyle('color: #000')
|
||||
})
|
||||
})
|
@ -54,7 +54,6 @@ export const SocialMediaButton: React.FC<SocialMediaButtonProps> = (props) => {
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
data-testid='social-media-button'
|
||||
{...rest}
|
||||
className={classNames(className, 'button', givenClassName)}
|
||||
>
|
||||
|
@ -1,10 +0,0 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { Textarea } from './Textarea'
|
||||
|
||||
describe('<Textarea />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(<Textarea label='Textarea' />)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user