-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
STCOR-689 STCOR-690 Support switch consortium active affiliation (#1308)
- Loading branch information
1 parent
7c3e75b
commit 15d2ee7
Showing
10 changed files
with
278 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/components/MainNav/ProfileDropdown/ProfileDropdown.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
|
||
import { ModulesContext } from '../../../ModulesContext'; | ||
import TestComponent from './ProfileDropdown'; | ||
|
||
jest.unmock('@folio/stripes-components'); | ||
jest.mock('currency-codes/data', () => ({ filter: () => [] })); | ||
|
||
const checkAction = jest.fn(() => true); | ||
const eventHandler = jest.fn(() => 'Handler content'); | ||
const modules = { | ||
app: [ | ||
{ | ||
displayName: 'Test app', | ||
handlerName: 'eventHandler', | ||
route: '/test', | ||
links: { | ||
userDropdown: [{ | ||
event: 'TEST_EVENT', | ||
caption: 'Profile dropdown action', | ||
check: 'checkAction', | ||
}] | ||
}, | ||
getModule: jest.fn(() => ({ | ||
checkAction, | ||
eventHandler, | ||
})), | ||
}, | ||
], | ||
}; | ||
|
||
const tenant = 'test'; | ||
const stripes = { | ||
user: { | ||
user: { | ||
id: 'user-id', | ||
tenants: [{ | ||
id: tenant, | ||
name: 'Central office', | ||
}] | ||
}, | ||
}, | ||
okapi: { | ||
tenant, | ||
}, | ||
}; | ||
|
||
const defaultProps = { | ||
onLogout: jest.fn(), | ||
stripes, | ||
}; | ||
|
||
const wrapper = ({ children }) => ( | ||
<MemoryRouter> | ||
<ModulesContext.Provider value={modules}> | ||
{children} | ||
</ModulesContext.Provider> | ||
</MemoryRouter> | ||
); | ||
|
||
const renderProfileDropdown = (props = {}) => render( | ||
<TestComponent | ||
{...defaultProps} | ||
{...props} | ||
/>, | ||
{ wrapper }, | ||
); | ||
|
||
describe('ProfileDropdown', () => { | ||
it('should display current consortium (if enabled) in the dropdown trigger', () => { | ||
renderProfileDropdown(); | ||
|
||
expect(screen.getByText('Central office')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display module profile dropdown item', () => { | ||
renderProfileDropdown(); | ||
|
||
expect(checkAction).toBeCalled(); | ||
expect(screen.getByText('Profile dropdown action')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.