Skip to content

Commit

Permalink
test(viewlabs): add test - findAll called with sort request
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-ap committed Apr 22, 2020
1 parent d026ae7 commit d55dbb7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/__tests__/labs/ViewLabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import LabRepository from 'clients/db/LabRepository'
import Lab from 'model/Lab'
import format from 'date-fns/format'
import * as ButtonBarProvider from 'page-header/ButtonBarProvider'
import SortRequest from 'clients/db/SortRequest'
import * as titleUtil from '../../page-header/useTitle'

const mockStore = configureMockStore([thunk])
Expand Down Expand Up @@ -160,4 +161,37 @@ describe('View Labs', () => {
expect(history.location.pathname).toEqual(`/labs/${expectedLab.id}`)
})
})

describe('sort Request', () => {
let findAllSpy: any
beforeEach(async () => {
const store = mockStore({
title: '',
user: { permissions: [Permissions.ViewLabs, Permissions.RequestLab] },
})
findAllSpy = jest.spyOn(LabRepository, 'findAll')
findAllSpy.mockResolvedValue([])
await act(async () => {
await mount(
<Provider store={store}>
<Router history={createMemoryHistory()}>
<ViewLabs />
</Router>
</Provider>,
)
})
})

it('should have called findAll with sort request', () => {
const sortRequest: SortRequest = {
sorts: [
{
field: 'requestedOn',
direction: 'desc',
},
],
}
expect(findAllSpy).toHaveBeenCalledWith(sortRequest)
})
})
})

0 comments on commit d55dbb7

Please sign in to comment.