From 3cfe5f4ce1d4bf9325d8d32892db77db0c5fba22 Mon Sep 17 00:00:00 2001 From: Priyanka Terala Date: Wed, 10 Jul 2024 17:37:36 +0530 Subject: [PATCH] UITEN-301 - add unit tests --- src/settings/index.test.js | 21 +++++++++++++++++++++ test/jest/__new_mocks__/stripesCore.mock.js | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/settings/index.test.js b/src/settings/index.test.js index d9778acd..d77e36c7 100644 --- a/src/settings/index.test.js +++ b/src/settings/index.test.js @@ -36,10 +36,12 @@ describe('Organization', () => { }; stripes.setIsAuthenticated = jest.fn(); stripes.hasInterface = jest.fn().mockReturnValue(false); + stripes.hasPerm = jest.fn().mockReturnValue(false); }); it('should render SSO Settings when login-saml interface is present', () => { stripes.hasInterface = jest.fn().mockReturnValue(true); + stripes.hasPerm = jest.fn().mockReturnValue(true); const { queryByText } = renderWithRouter(); expect(queryByText('ui-tenant-settings.settings.ssoSettings.label')).toBeTruthy(); }); @@ -48,4 +50,23 @@ describe('Organization', () => { const { queryByText } = renderWithRouter(); expect(queryByText('ui-tenant-settings.settings.ssoSettings.label')).toBeNull(); }); + + it('should render Reading room access when associated permission and interface are present', () => { + stripes.hasInterface = jest.fn().mockReturnValue(true); + stripes.hasPerm = jest.fn().mockReturnValue(true); + const { queryByText } = renderWithRouter(); + expect(queryByText('ui-tenant-settings.settings.reading-room-access.label')).toBeTruthy(); + }); + + it('should not render Reading room access when ui-tenant-settings.settings.reading-room-access.view permission is not present', () => { + stripes.hasInterface = jest.fn().mockReturnValue(true); + const { queryByText } = renderWithRouter(); + expect(queryByText('ui-tenant-settings.settings.reading-room-access.label')).toBeNull(); + }); + + it('should not render Reading room access when reading-room interface is not present', () => { + stripes.hasPerm = jest.fn().mockReturnValue(true); + const { queryByText } = renderWithRouter(); + expect(queryByText('ui-tenant-settings.settings.reading-room-access.label')).toBeNull(); + }); }); diff --git a/test/jest/__new_mocks__/stripesCore.mock.js b/test/jest/__new_mocks__/stripesCore.mock.js index 2b1d3773..9fb3bd2b 100644 --- a/test/jest/__new_mocks__/stripesCore.mock.js +++ b/test/jest/__new_mocks__/stripesCore.mock.js @@ -10,7 +10,7 @@ const buildStripes = (otherProperties = {}) => ({ }, currency: 'USD', hasInterface: () => true, - hasPerm: jest.fn(() => true), + hasPerm: () => true, locale: 'en-US', logger: { log: () => { },