Skip to content

Commit

Permalink
UITEN-301 - add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Terala-Priyanka committed Jul 10, 2024
1 parent 5e43c15 commit 3cfe5f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/settings/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(<Organization {...props} />);
expect(queryByText('ui-tenant-settings.settings.ssoSettings.label')).toBeTruthy();
});
Expand All @@ -48,4 +50,23 @@ describe('Organization', () => {
const { queryByText } = renderWithRouter(<Organization {...props} />);
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(<Organization {...props} />);
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(<Organization {...props} />);
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(<Organization {...props} />);
expect(queryByText('ui-tenant-settings.settings.reading-room-access.label')).toBeNull();
});
});
2 changes: 1 addition & 1 deletion test/jest/__new_mocks__/stripesCore.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const buildStripes = (otherProperties = {}) => ({
},
currency: 'USD',
hasInterface: () => true,
hasPerm: jest.fn(() => true),
hasPerm: () => true,
locale: 'en-US',
logger: {
log: () => { },
Expand Down

0 comments on commit 3cfe5f4

Please sign in to comment.