|
1 | 1 | import React from 'react'
|
2 |
| -import {act, render, screen} from '@testing-library/react' |
| 2 | +import {act, fireEvent, render, screen} from '@testing-library/react' |
3 | 3 | import MatchMediaMock from 'jest-matchmedia-mock'
|
4 | 4 | import 'react-intersection-observer/test-utils'
|
5 | 5 | import {ThemeProvider} from '..'
|
6 | 6 | import {viewportRanges} from '../hooks/useResponsiveValue'
|
7 | 7 | import {PageLayout} from './PageLayout'
|
| 8 | +import {Placeholder} from '../Placeholder' |
8 | 9 |
|
9 | 10 | let matchMedia: MatchMediaMock
|
10 | 11 |
|
@@ -171,5 +172,32 @@ describe('PageLayout', () => {
|
171 | 172 | )
|
172 | 173 | expect(ref).toHaveBeenCalledWith(screen.getByTestId('content').parentNode)
|
173 | 174 | })
|
| 175 | + |
| 176 | + it('should be resizable if `resizable` is set correctly', async () => { |
| 177 | + render( |
| 178 | + <ThemeProvider> |
| 179 | + <PageLayout> |
| 180 | + <PageLayout.Pane resizable> |
| 181 | + <Placeholder height={320} label="Pane" /> |
| 182 | + </PageLayout.Pane> |
| 183 | + <PageLayout.Content> |
| 184 | + <Placeholder height={640} label="Content" /> |
| 185 | + </PageLayout.Content> |
| 186 | + </PageLayout> |
| 187 | + </ThemeProvider>, |
| 188 | + ) |
| 189 | + |
| 190 | + const placeholder = await screen.findByText('Pane') |
| 191 | + const pane = placeholder.parentNode |
| 192 | + const initialWidth = (pane as HTMLElement).style.getPropertyValue('--pane-width') |
| 193 | + |
| 194 | + const divider = await screen.findByRole('separator') |
| 195 | + // Moving divider should resize pane. |
| 196 | + fireEvent.mouseDown(divider) |
| 197 | + fireEvent.mouseMove(divider) |
| 198 | + fireEvent.mouseUp(divider) |
| 199 | + const finalWidth = (pane as HTMLElement).style.getPropertyValue('--pane-width') |
| 200 | + expect(finalWidth).not.toEqual(initialWidth) |
| 201 | + }) |
174 | 202 | })
|
175 | 203 | })
|
0 commit comments