File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ describe('Account navigation button', () => {
3030
3131 const config = {
3232 multitenancy : {
33- enabled : ' true' ,
33+ enabled : true ,
3434 tenants : {
35- enable_private : ' true' ,
36- enable_global : ' true' ,
35+ enable_private : true ,
36+ enable_global : true ,
3737 } ,
3838 } ,
3939 auth : {
@@ -102,3 +102,43 @@ describe('Account navigation button', () => {
102102 expect ( setState ) . toBeCalledTimes ( 1 ) ;
103103 } ) ;
104104} ) ;
105+
106+ describe ( 'Account navigation button, multitenancy disabled' , ( ) => {
107+ const mockCoreStart = {
108+ http : 1 ,
109+ } ;
110+
111+ const config = {
112+ multitenancy : {
113+ enabled : false ,
114+ } ,
115+ auth : {
116+ type : 'dummy' ,
117+ } ,
118+ } ;
119+
120+ const userName = 'user1' ;
121+ const setState = jest . fn ( ) ;
122+ const useStateSpy = jest . spyOn ( React , 'useState' ) ;
123+
124+ beforeEach ( ( ) => {
125+ useStateSpy . mockImplementation ( ( init ) => [ init , setState ] ) ;
126+ } ) ;
127+
128+ afterEach ( ( ) => {
129+ jest . clearAllMocks ( ) ;
130+ } ) ;
131+
132+ it ( 'should not set modal when show popup is true' , ( ) => {
133+ ( getShouldShowTenantPopup as jest . Mock ) . mockReturnValueOnce ( true ) ;
134+ shallow (
135+ < AccountNavButton
136+ coreStart = { mockCoreStart }
137+ isInternalUser = { true }
138+ username = { userName }
139+ config = { config as any }
140+ />
141+ ) ;
142+ expect ( setState ) . toBeCalledTimes ( 0 ) ;
143+ } ) ;
144+ } ) ;
You can’t perform that action at this time.
0 commit comments