forked from folio-org/ui-inventory
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIIN-1970: Show inactive locations on instance view (folio-org#1845)
Co-authored-by: Michal Kuklis <[email protected]>
- Loading branch information
1 parent
7c04855
commit 565144a
Showing
12 changed files
with
163 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
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from 'react'; | ||
import { QueryClient, QueryClientProvider } from 'react-query'; | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
import { act } from 'react-dom/test-utils'; | ||
import { screen } from '@testing-library/react'; | ||
|
||
import '../../../../test/jest/__mock__'; | ||
|
||
import DataContext from '../../../contexts/DataContext'; | ||
|
||
import { items as itemsFixture } from '../../../../test/fixtures/items'; | ||
import { holdingsRecords as holdingsRecordsFixture } from '../../../../test/fixtures/holdingsRecords'; | ||
import renderWithIntl from '../../../../test/jest/helpers/renderWithIntl'; | ||
import translations from '../../../../test/jest/helpers/translationsProperties'; | ||
import ItemsList from '../ItemsList'; | ||
import useHoldingItemsQuery from '../../../hooks/useHoldingItemsQuery'; | ||
|
||
jest.mock('../../../hooks/useHoldingItemsQuery', () => jest.fn()); | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
const locations = { | ||
'fcd64ce1-6995-48f0-840e-89ffa2288371': | ||
{ | ||
id: 'fcd64ce1-6995-48f0-840e-89ffa2288371', | ||
name: 'Main Library', | ||
isActive: true, | ||
}, | ||
'fcd64ce1-6995-48f0-840e-89ffa2288372' : | ||
{ | ||
id: 'fcd64ce1-6995-48f0-840e-89ffa2288372', | ||
name: 'Annex', | ||
isActive: false, | ||
}, | ||
}; | ||
|
||
const ItemsListSetup = () => ( | ||
<QueryClientProvider client={queryClient}> | ||
<Router> | ||
<DataContext.Provider value={{ locationsById: locations }}> | ||
<ItemsList | ||
items={itemsFixture} | ||
holding={holdingsRecordsFixture[0]} | ||
isItemsDragSelected={(_) => false} | ||
selectItemsForDrag={(_) => {}} | ||
getDraggingItems={jest.fn()} | ||
draggable={false} | ||
/> | ||
</DataContext.Provider> | ||
</Router> | ||
</QueryClientProvider> | ||
); | ||
|
||
describe('ItemsList', () => { | ||
beforeEach(async () => { | ||
useHoldingItemsQuery.mockReturnValue({ | ||
isFetching: false, | ||
totalRecords: itemsFixture.length, | ||
}); | ||
|
||
await act(async () => { | ||
await renderWithIntl(<ItemsListSetup />, translations); | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should display "inactive" by a location if applicable', () => { | ||
expect(screen.queryByText('Inactive')).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
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,5 @@ | ||
export const holdingsRecords = [ | ||
{ | ||
id: '44a21d17-a666-4f34-b24d-644f8ed1537b', | ||
} | ||
]; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
jest.mock('react-beautiful-dnd', () => ({ | ||
Droppable: ({ children }) => children({ | ||
draggableProps: { | ||
style: {}, | ||
}, | ||
innerRef: jest.fn(), | ||
}, {}), | ||
Draggable: ({ children }) => children({ | ||
draggableProps: { | ||
style: {}, | ||
}, | ||
innerRef: jest.fn(), | ||
}, {}), | ||
DragDropContext: ({ children }) => children, | ||
})); |
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