@@ -42,6 +42,37 @@ test('renders everything provided', () => {
4242 expect ( wrapper . findActions ( ) ! . find ( 'button' ) ! . getElement ( ) ) . toHaveTextContent ( 'Click me' ) ;
4343} ) ;
4444
45+ describe ( 'secondary content' , ( ) => {
46+ test ( 'is not rendered by default' , ( ) => {
47+ const { wrapper } = renderHeader ( < Header > Test title</ Header > ) ;
48+ expect ( wrapper . findSecondaryContent ( ) ) . toBeNull ( ) ;
49+ } ) ;
50+
51+ test . each ( [ 'h1' , 'h2' , 'h3' , 'awsui-h1-sticky' ] as const ) ( 'renders outside the heading element for %s' , variant => {
52+ const { wrapper } = renderHeader (
53+ < Header variant = { variant } secondaryContent = { < button > Filter</ button > } >
54+ Test title
55+ </ Header >
56+ ) ;
57+ const secondaryContent = wrapper . findSecondaryContent ( ) ! . getElement ( ) ;
58+ expect ( secondaryContent ) . toHaveTextContent ( 'Filter' ) ;
59+ expect ( secondaryContent . closest ( 'h1,h2,h3,h4,h5,h6' ) ) . toBeNull ( ) ;
60+ } ) ;
61+
62+ test ( 'renders between the title and the actions' , ( ) => {
63+ const { wrapper } = renderHeader (
64+ < Header info = "Info" secondaryContent = { < button > Filter</ button > } actions = { < button > Create</ button > } >
65+ Test title
66+ </ Header >
67+ ) ;
68+ const info = wrapper . findInfo ( ) ! . getElement ( ) ;
69+ const secondaryContent = wrapper . findSecondaryContent ( ) ! . getElement ( ) ;
70+ const actions = wrapper . findActions ( ) ! . getElement ( ) ;
71+ expect ( info . compareDocumentPosition ( secondaryContent ) & Node . DOCUMENT_POSITION_FOLLOWING ) . toBeTruthy ( ) ;
72+ expect ( secondaryContent . compareDocumentPosition ( actions ) & Node . DOCUMENT_POSITION_FOLLOWING ) . toBeTruthy ( ) ;
73+ } ) ;
74+ } ) ;
75+
4576test ( 'renders arbitrary counter content' , ( ) => {
4677 const { wrapper } = renderHeader ( < Header counter = { < Spinner /> } /> ) ;
4778 expect ( wrapper . findCounter ( ) ) . not . toBeNull ( ) ;
0 commit comments