Skip to content

Commit

Permalink
Add tests for account-nav-button when multitenancy is disabled (#1020)
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <cwperx@amazon.com>
(cherry picked from commit 4527d1a)
  • Loading branch information
cwperks authored and github-actions[bot] committed Jul 6, 2022
1 parent c1404df commit deefe71
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions public/apps/account/test/account-nav-button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ describe('Account navigation button', () => {

const config = {
multitenancy: {
enabled: 'true',
enabled: true,
tenants: {
enable_private: 'true',
enable_global: 'true',
enable_private: true,
enable_global: true,
},
},
auth: {
Expand Down Expand Up @@ -102,3 +102,43 @@ describe('Account navigation button', () => {
expect(setState).toBeCalledTimes(1);
});
});

describe('Account navigation button, multitenancy disabled', () => {
const mockCoreStart = {
http: 1,
};

const config = {
multitenancy: {
enabled: false,
},
auth: {
type: 'dummy',
},
};

const userName = 'user1';
const setState = jest.fn();
const useStateSpy = jest.spyOn(React, 'useState');

beforeEach(() => {
useStateSpy.mockImplementation((init) => [init, setState]);
});

afterEach(() => {
jest.clearAllMocks();
});

it('should not set modal when show popup is true', () => {
(getShouldShowTenantPopup as jest.Mock).mockReturnValueOnce(true);
shallow(
<AccountNavButton
coreStart={mockCoreStart}
isInternalUser={true}
username={userName}
config={config as any}
/>
);
expect(setState).toBeCalledTimes(0);
});
});

0 comments on commit deefe71

Please sign in to comment.