Skip to content

Commit

Permalink
test: Update to use CozyTheme
Browse files Browse the repository at this point in the history
  • Loading branch information
Crash-- committed Jan 3, 2024
1 parent 73571c0 commit 312c1be
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 246 deletions.
6 changes: 3 additions & 3 deletions src/components/AddButton/AddButton.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import flag from 'cozy-flags'
import { useQuery } from 'cozy-client'

import AppLike from 'test/AppLike'
import MuiCozyTheme from 'cozy-ui/transpiled/react/MuiCozyTheme'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
import AddButton from './AddButton'

import { FLAG_FAB_ACTIONS } from './helpers'
Expand Down Expand Up @@ -67,9 +67,9 @@ jest.mock('cozy-flags')
const setup = () => {
const root = render(
<AppLike>
<MuiCozyTheme>
<CozyTheme>
<AddButton />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)
return { root }
Expand Down
38 changes: 19 additions & 19 deletions src/components/AppTile.spec.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AppLike from 'test/AppLike'
import AppTileWrapper from './AppTile'
import MuiCozyTheme from 'cozy-ui/transpiled/react/MuiCozyTheme'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
import React from 'react'
import { act } from 'react-dom/test-utils'
import { render, waitFor, screen } from '@testing-library/react'
Expand Down Expand Up @@ -43,11 +43,11 @@ describe('<AppTile />', () => {
it('renders loading icon when app is in installing state', () => {
const { getByText } = render(
<AppLike>
<MuiCozyTheme>
<CozyTheme>
<I18n dictRequire={() => enLocale} lang="en">
<AppTileWrapper app={mockAppInstalling} lang="en" />
</I18n>
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)

Expand All @@ -57,11 +57,11 @@ describe('<AppTile />', () => {
it('renders loading icon when app is in upgrading state', () => {
const { getByText } = render(
<AppLike>
<MuiCozyTheme>
<CozyTheme>
<I18n dictRequire={() => enLocale} lang="en">
<AppTileWrapper app={mockAppUpgrading} lang="en" />
</I18n>
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)

Expand All @@ -71,9 +71,9 @@ describe('<AppTile />', () => {
it('renders AppTile when app is in ready state', async () => {
const { queryByText } = render(
<AppLike client={mockClient}>
<MuiCozyTheme>
<CozyTheme>
<AppTileWrapper app={mockAppReady} lang="en" />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)

Expand All @@ -83,18 +83,18 @@ describe('<AppTile />', () => {
it('updates app state from installing to ready and fetches app info', async () => {
const { rerender } = render(
<AppLike client={mockClient}>
<MuiCozyTheme>
<CozyTheme>
<AppTileWrapper app={mockAppInstalling} lang="en" />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)

await act(async () => {
rerender(
<AppLike client={mockClient}>
<MuiCozyTheme>
<CozyTheme>
<AppTileWrapper app={mockAppReady} lang="en" />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)
})
Expand All @@ -108,18 +108,18 @@ describe('<AppTile />', () => {
it('updates app state from upgrading to ready and fetches app info', async () => {
const { rerender } = render(
<AppLike client={mockClient}>
<MuiCozyTheme>
<CozyTheme>
<AppTileWrapper app={mockAppUpgrading} lang="en" />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)

await act(async () => {
rerender(
<AppLike client={mockClient}>
<MuiCozyTheme>
<CozyTheme>
<AppTileWrapper app={mockAppReady} lang="en" />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)
})
Expand All @@ -133,18 +133,18 @@ describe('<AppTile />', () => {
it('does not update app state from installing to ready if app state is not ready', async () => {
const { rerender } = render(
<AppLike client={mockClient}>
<MuiCozyTheme>
<CozyTheme>
<AppTileWrapper app={mockAppInstalling} lang="en" />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)

await waitFor(() => {
rerender(
<AppLike client={mockClient}>
<MuiCozyTheme>
<CozyTheme>
<AppTileWrapper app={mockAppInstalling} lang="en" />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { render, fireEvent } from '@testing-library/react'

import MuiCozyTheme from 'cozy-ui/transpiled/react/MuiCozyTheme'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'

import AppLike from 'test/AppLike'
import DefaultRedirectionSnackbar from './DefaultRedirectionSnackbar'
Expand All @@ -22,9 +22,9 @@ jest.mock('./useIncrementDefaultRedirectionViewCount')
const setup = () => {
const root = render(
<AppLike>
<MuiCozyTheme>
<CozyTheme>
<DefaultRedirectionSnackbar />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)
return { root }
Expand Down
6 changes: 3 additions & 3 deletions src/components/KonnectorTile.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import React from 'react'
import { render } from '@testing-library/react'
import MuiCozyTheme from 'cozy-ui/transpiled/react/MuiCozyTheme'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
import { createMockClient } from 'cozy-client/dist/mock'

import {
Expand Down Expand Up @@ -160,9 +160,9 @@ const setup = mockProps => {
})
return render(
<AppLike client={client} store={client.store}>
<MuiCozyTheme>
<CozyTheme>
<KonnectorTile {...mockProps} />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Services.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useAppsInMaintenance } from 'cozy-client'
import { createMockClient } from 'cozy-client/dist/mock'
import { Services } from './Services'
import AppLike from 'test/AppLike'
import MuiCozyTheme from 'cozy-ui/transpiled/react/MuiCozyTheme'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'

jest.mock('cozy-client', () => ({
...jest.requireActual('cozy-client'),
Expand Down Expand Up @@ -54,12 +54,12 @@ describe('Services component', () => {
useAppsInMaintenance.mockReturnValue(appsAndKonnectorsInMaintenance)
const root = render(
<AppLike client={client} store={client.store}>
<MuiCozyTheme>
<CozyTheme>
<Services
installedKonnectors={installedKonnectors || []}
suggestedKonnectorsQuery={suggestedKonnectorsQuery || { data: [] }}
/>
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)
return { root }
Expand Down
10 changes: 5 additions & 5 deletions src/components/ShortcutLink.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '@testing-library/jest-dom'

import { ShortcutLink } from './ShortcutLink'
import { useFetchShortcut } from 'cozy-client'
import MuiCozyTheme from 'cozy-ui/transpiled/react/MuiCozyTheme'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'

jest.mock('cozy-client', () => {
return {
Expand All @@ -27,9 +27,9 @@ describe('ShortcutLink', () => {
const file = { _id: '123', name: 'cozy.io.url', type: 'file' }

render(
<MuiCozyTheme>
<CozyTheme>
<ShortcutLink file={file} />
</MuiCozyTheme>
</CozyTheme>
)

expect(screen.getByRole('heading', { level: 6 })).toHaveTextContent(
Expand All @@ -53,9 +53,9 @@ describe('ShortcutLink', () => {
const file = { _id: '123', name: 'cozy.io.url', type: 'file' }

render(
<MuiCozyTheme>
<CozyTheme>
<ShortcutLink file={file} />
</MuiCozyTheme>
</CozyTheme>
)

expect(screen.getByRole('heading', { level: 6 })).toHaveTextContent(
Expand Down
16 changes: 8 additions & 8 deletions src/components/Shortcuts/ShortcutsView.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import '@testing-library/jest-dom'

import { ShortcutsView } from './ShortcutsView'
import AppLike from 'test/AppLike'
import MuiCozyTheme from 'cozy-ui/transpiled/react/MuiCozyTheme'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'

describe('Shortcuts', () => {
it('Should display nothing if nothing was found', () => {
const { container } = render(
<AppLike>
<MuiCozyTheme>
<CozyTheme>
<ShortcutsView shortcutsDirectories={null} />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)
expect(container).toBeEmptyDOMElement()
expect(container).toMatchSnapshot()
})

it('Should display a shortcut directory with its files', async () => {
Expand All @@ -25,13 +25,13 @@ describe('Shortcuts', () => {

const root = render(
<AppLike>
<MuiCozyTheme>
<CozyTheme>
<ShortcutsView
shortcutsDirectories={[
{ name: listName, shortcuts: [{ name: listItem }] }
]}
/>
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)
expect(root).toMatchSnapshot()
Expand All @@ -45,9 +45,9 @@ describe('Shortcuts', () => {

const root = render(
<AppLike>
<MuiCozyTheme>
<CozyTheme>
<ShortcutsView shortcutsDirectories={shortcutsDirectories} />
</MuiCozyTheme>
</CozyTheme>
</AppLike>
)

Expand Down
Loading

0 comments on commit 312c1be

Please sign in to comment.