File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const StyledWindow = styled.div`
1010 ${ createBorderStyles ( { windowBorders : true } ) }
1111 ${ createBoxStyles ( ) }
1212` ;
13- const DragHandle = styled . span `
13+ const ResizeHandle = styled . span `
1414 ${ ( { theme } ) => css `
1515 display: inline-block;
1616 position: absolute;
@@ -41,11 +41,13 @@ const DragHandle = styled.span`
4141 ` }
4242` ;
4343
44- // TODO pass resize handler
44+ // TODO how to pass event handlers to resize handler?
45+ // TODO how to pass refs to both Window component and DragHandle?
46+
4547const Window = ( { resizable, shadow, children, ...otherProps } ) => (
4648 < StyledWindow shadow = { shadow } { ...otherProps } >
4749 { children }
48- { resizable && < DragHandle /> }
50+ { resizable && < ResizeHandle data-testid = 'resizeHandle' /> }
4951 </ StyledWindow >
5052) ;
5153
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ import { renderWithTheme } from '../../../test/utils' ;
4+
5+ import Window from './Window' ;
6+
7+ describe ( '<Window />' , ( ) => {
8+ it ( 'renders Window' , ( ) => {
9+ const { container } = renderWithTheme ( < Window /> ) ;
10+ const window = container . firstChild ;
11+
12+ expect ( window ) . toBeInTheDocument ( ) ;
13+ } ) ;
14+
15+ it ( 'renders children' , ( ) => {
16+ const textContent = 'Hi there!' ;
17+ const { getByText } = renderWithTheme (
18+ < Window >
19+ < span > { textContent } </ span >
20+ </ Window >
21+ ) ;
22+ expect ( getByText ( textContent ) ) . toBeInTheDocument ( ) ;
23+ } ) ;
24+
25+ describe ( 'prop: resizable' , ( ) => {
26+ it ( 'does not render resize handle by default' , ( ) => {
27+ const { queryByTestId } = renderWithTheme ( < Window /> ) ;
28+
29+ expect ( queryByTestId ( 'resizeHandle' ) ) . not . toBeInTheDocument ( ) ;
30+ } ) ;
31+ it ( 'renders resize handle when set to true' , ( ) => {
32+ const { queryByTestId } = renderWithTheme ( < Window resizable /> ) ;
33+
34+ expect ( queryByTestId ( 'resizeHandle' ) ) . toBeInTheDocument ( ) ;
35+ } ) ;
36+ } ) ;
37+ } ) ;
You can’t perform that action at this time.
0 commit comments