Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for account-nav-button when multitenancy is disabled #1020

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
cliu123 marked this conversation as resolved.
Show resolved Hide resolved
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);
});
});