From 61829071d35570de53f775b6bfe83e291631a330 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 6 Jul 2022 15:04:05 -0400 Subject: [PATCH] Add tests for account-nav-button when multitenancy is disabled (#1020) Signed-off-by: Craig Perkins Signed-off-by: Vasile Negru --- .../account/test/account-nav-button.test.tsx | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/public/apps/account/test/account-nav-button.test.tsx b/public/apps/account/test/account-nav-button.test.tsx index 14fa038ff..d68f00912 100644 --- a/public/apps/account/test/account-nav-button.test.tsx +++ b/public/apps/account/test/account-nav-button.test.tsx @@ -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: { @@ -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( + + ); + expect(setState).toBeCalledTimes(0); + }); +});