Skip to content

Commit ee617d6

Browse files
Add tests for account-nav-button when multitenancy is disabled (#1020) (#1022)
Signed-off-by: Craig Perkins <cwperx@amazon.com> (cherry picked from commit 4527d1a) Co-authored-by: Craig Perkins <craig5008@gmail.com>
1 parent c1404df commit ee617d6

1 file changed

Lines changed: 43 additions & 3 deletions

File tree

public/apps/account/test/account-nav-button.test.tsx

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff 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+
});

0 commit comments

Comments
 (0)