@@ -5,15 +5,11 @@ import { fireEvent, render } from '@testing-library/react';
5
5
6
6
import { KeyCode } from '@cloudscape-design/test-utils-core/utils' ;
7
7
8
- import TestI18nProvider from '../../../lib/components/i18n/testing' ;
9
- import {
10
- SplitPanelContextProps ,
11
- SplitPanelContextProvider ,
12
- } from '../../../lib/components/internal/context/split-panel-context' ;
13
- import SplitPanel , { SplitPanelProps } from '../../../lib/components/split-panel' ;
8
+ import SplitPanel from '../../../lib/components/split-panel' ;
14
9
import createWrapper from '../../../lib/components/test-utils/dom' ;
15
10
import { testIf } from '../../__tests__/utils' ;
16
11
import { describeEachAppLayout } from '../../app-layout/__tests__/utils' ;
12
+ import { defaultProps , renderSplitPanel } from './common' ;
17
13
import { defaultSplitPanelContextProps } from './helpers' ;
18
14
19
15
import styles from '../../../lib/components/split-panel/styles.css.js' ;
@@ -29,48 +25,6 @@ jest.mock('../../../lib/components/app-layout/utils/use-pointer-events', () => (
29
25
usePointerEvents : ( ) => onSliderPointerDown ,
30
26
} ) ) ;
31
27
32
- const i18nStrings = {
33
- closeButtonAriaLabel : 'closeButtonAriaLabel' ,
34
- openButtonAriaLabel : 'openButtonAriaLabel' ,
35
- preferencesTitle : 'preferencesTitle' ,
36
- preferencesPositionLabel : 'preferencesPositionLabel' ,
37
- preferencesPositionDescription : 'preferencesPositionDescription' ,
38
- preferencesPositionSide : 'preferencesPositionSide' ,
39
- preferencesPositionBottom : 'preferencesPositionBottom' ,
40
- preferencesConfirm : 'preferencesConfirm' ,
41
- preferencesCancel : 'preferencesCancel' ,
42
- resizeHandleAriaLabel : 'resizeHandleAriaLabel' ,
43
- } ;
44
-
45
- const defaultProps : SplitPanelProps = {
46
- header : 'Split panel header' ,
47
- children : < p > Split panel content</ p > ,
48
- hidePreferencesButton : undefined ,
49
- i18nStrings,
50
- } ;
51
-
52
- function renderSplitPanel ( {
53
- props,
54
- contextProps,
55
- messages = { } ,
56
- modalMessages = { } ,
57
- } : {
58
- props ?: Partial < SplitPanelProps > ;
59
- contextProps ?: Partial < SplitPanelContextProps > ;
60
- messages ?: Record < string , string > ;
61
- modalMessages ?: Record < string , string > ;
62
- } = { } ) {
63
- const { container } = render (
64
- < TestI18nProvider messages = { { 'split-panel' : messages , modal : modalMessages } } >
65
- < SplitPanelContextProvider value = { { ...defaultSplitPanelContextProps , ...contextProps } } >
66
- < SplitPanel { ...defaultProps } { ...props } />
67
- </ SplitPanelContextProvider >
68
- </ TestI18nProvider >
69
- ) ;
70
- const wrapper = createWrapper ( container ) . findSplitPanel ( ) ;
71
- return { wrapper } ;
72
- }
73
-
74
28
afterEach ( ( ) => {
75
29
jest . clearAllMocks ( ) ;
76
30
} ) ;
0 commit comments