@@ -15,6 +15,7 @@ const renderComponent = ({ channelStateContextMock, children, props }) =>
1515 ) ;
1616
1717const thread = generateMessage ( ) ;
18+ const HIDE_CLASS_NAME = 'str-chat__main-panel--hideOnThread' ;
1819
1920describe ( 'Window' , ( ) => {
2021 it ( 'should render its children if hideOnThread is false and thread is truthy' , ( ) => {
@@ -40,4 +41,30 @@ describe('Window', () => {
4041
4142 expect ( getByText ( 'bla' ) ) . toBeInTheDocument ( ) ;
4243 } ) ;
44+ it . each ( [
45+ [ 'not add' , 'truthy' , 'falsy' , 'falsy' , true , undefined , undefined ] ,
46+ [ 'add' , 'truthy' , 'truthy' , 'falsy' , true , thread , undefined ] ,
47+ [ 'add' , 'truthy' , 'falsy' , 'truthy' , true , undefined , thread ] ,
48+ [ 'add' , 'truthy' , 'truthy' , 'truthy' , true , thread , thread ] ,
49+ [ 'not add' , 'falsy' , 'falsy' , 'falsy' , false , undefined , undefined ] ,
50+ [ 'not add' , 'falsy' , 'truthy' , 'falsy' , false , thread , undefined ] ,
51+ [ 'not add' , 'falsy' , 'falsy' , 'truthy' , false , undefined , thread ] ,
52+ [ 'not add' , 'falsy' , 'truthy' , 'truthy' , false , thread , thread ] ,
53+ ] ) (
54+ 'should %s class str-chat__main-panel--hideOnThread if hideOnThread is %s, prop thread is %s, context thread is %s' ,
55+ ( expectation , _ , __ , ___ , hideOnThread , propThread , contextThread ) => {
56+ const { container } = renderComponent ( {
57+ channelStateContextMock : {
58+ thread : contextThread ,
59+ } ,
60+ children : [ < div key = 'bla' > bla</ div > ] ,
61+ props : { hideOnThread, thread : propThread } ,
62+ } ) ;
63+
64+ if ( expectation === 'add' )
65+ expect ( container . querySelector ( `.${ HIDE_CLASS_NAME } ` ) ) . toBeInTheDocument ( ) ;
66+ if ( expectation === 'not add' )
67+ expect ( container . querySelector ( `.${ HIDE_CLASS_NAME } ` ) ) . not . toBeInTheDocument ( ) ;
68+ } ,
69+ ) ;
4370} ) ;
0 commit comments