-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
70 additions
and
16 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
.../activities/open-all-room-activities/__snapshots__/open-all-room-activities.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`features/activities/open-all-room-activities/open-all-room-activities > should render link looks like button 1`] = ` | ||
<a | ||
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium css-1e6y48t-MuiButtonBase-root-MuiButton-root" | ||
href="/rooms/123/activities" | ||
tabindex="0" | ||
> | ||
blocks.last_activities.actions.open | ||
<span | ||
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root" | ||
/> | ||
</a> | ||
`; |
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
src/features/activities/open-all-room-activities/open-all-room-activities.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { RenderResult, fireEvent, render } from '@testing-library/react'; | ||
import { RouterProvider } from 'atomic-router-react'; | ||
import { Scope, allSettled, fork } from 'effector'; | ||
import { Provider } from 'effector-react'; | ||
import { createMemoryHistory } from 'history'; | ||
import { beforeEach, describe, expect, test } from 'vitest'; | ||
|
||
import { router, routes } from '@/shared/configs'; | ||
|
||
import { OpenAllRoomActivities } from './open-all-room-activities'; | ||
|
||
describe('features/activities/open-all-room-activities/open-all-room-activities', () => { | ||
let wrapper: RenderResult; | ||
let scope: Scope; | ||
const roomId = 123; | ||
|
||
const createComponent = () => { | ||
wrapper = render( | ||
<Provider value={scope}> | ||
<RouterProvider router={router}> | ||
<OpenAllRoomActivities /> | ||
</RouterProvider> | ||
</Provider> | ||
); | ||
}; | ||
const findLink = () => | ||
wrapper.getByRole('link', { name: 'blocks.last_activities.actions.open', }); | ||
|
||
beforeEach(async () => { | ||
scope = fork(); | ||
await allSettled(router.setHistory, { | ||
scope, | ||
params: createMemoryHistory(), | ||
}); | ||
await allSettled(routes.room.tasks.open, { | ||
scope, | ||
params: { id: roomId, }, | ||
}); | ||
}); | ||
|
||
test('should render link looks like button', () => { | ||
createComponent(); | ||
|
||
expect(findLink()).toMatchSnapshot(); | ||
}); | ||
|
||
test('should navigate to activities room on click', () => { | ||
createComponent(); | ||
|
||
const link = findLink(); | ||
|
||
fireEvent.click(link); | ||
|
||
expect(scope.getState(router.$path)).toBe(`/rooms/${roomId}/activities`); | ||
}); | ||
}); |