-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9dd70e7
commit 0b84249
Showing
4 changed files
with
50 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
import { coreEvents } from '@folio/stripes/core'; | ||
|
||
import InventoryRouting from './index'; | ||
import { removeItem } from './storage'; | ||
import { events } from './constants'; | ||
|
||
import { coreEvents } from '@folio/stripes/core'; | ||
jest.mock('./storage'); | ||
|
||
global.Storage.prototype.clear = jest.fn(); | ||
const searchTermsExpectations = () => { | ||
expect(removeItem).toHaveBeenNthCalledWith(1, '@folio/inventory/search.instances.lastSearch'); | ||
expect(removeItem).toHaveBeenNthCalledWith(2, '@folio/inventory/search.holdings.lastSearch'); | ||
expect(removeItem).toHaveBeenNthCalledWith(3, '@folio/inventory/search.items.lastSearch'); | ||
expect(removeItem).toHaveBeenNthCalledWith(4, '@folio/inventory/browse.lastSearch'); | ||
expect(removeItem).toHaveBeenNthCalledWith(5, '@folio/inventory/search.instances.lastOffset'); | ||
expect(removeItem).toHaveBeenNthCalledWith(6, '@folio/inventory/search.holdings.lastOffset'); | ||
expect(removeItem).toHaveBeenNthCalledWith(7, '@folio/inventory/search.items.lastOffset'); | ||
expect(removeItem).toHaveBeenNthCalledWith(8, '@folio/inventory/browse.lastOffset'); | ||
} | ||
Check failure on line 18 in src/index.test.js
|
||
|
||
describe('InventoryRouting', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe('when LOGIN event is fired', () => { | ||
it('should clear session storage', () => { | ||
describe('when the user logs in', () => { | ||
it('should reset search terms in session storage', () => { | ||
InventoryRouting.eventHandler(coreEvents.LOGIN); | ||
expect(sessionStorage.clear).toHaveBeenCalled(); | ||
searchTermsExpectations(); | ||
}); | ||
}); | ||
|
||
describe('when SWITCH_ACTIVE_AFFILIATION event is fired', () => { | ||
it('should clear session storage', () => { | ||
InventoryRouting.eventHandler('SWITCH_ACTIVE_AFFILIATION'); | ||
expect(sessionStorage.clear).toHaveBeenCalled(); | ||
describe('when the user switch affiliation', () => { | ||
it('should reset search terms in session storage', () => { | ||
InventoryRouting.eventHandler(events.SWITCH_ACTIVE_AFFILIATION); | ||
searchTermsExpectations(); | ||
}); | ||
}); | ||
}); |
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