Skip to content

Commit

Permalink
(PC-31778) fix(EndedBookings): fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
yleclercq-pass committed Sep 20, 2024
1 parent c39ad07 commit e4d0cb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { Fragment, FunctionComponent } from 'react'
import { QueryObserverResult } from 'react-query'

import { BookingsResponse } from 'api/gen'
import * as bookingsAPI from 'features/bookings/api/useBookings'
import { bookingsSnap } from 'features/bookings/fixtures/bookingsSnap'
import * as useGoBack from 'features/navigation/useGoBack'
import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
Expand Down Expand Up @@ -62,13 +60,6 @@ describe('EndedBookings', () => {
expect(screen).toMatchSnapshot()
})

it('should always execute the query (in cache or in network)', () => {
const useBookings = jest.spyOn(bookingsAPI, 'useBookings')
renderEndedBookings(bookingsSnap)

expect(useBookings).toHaveBeenCalledTimes(1)
})

it('should display the right number of ended bookings', () => {
renderEndedBookings(bookingsSnap)

Expand Down Expand Up @@ -107,11 +98,9 @@ const renderEndedBookings = (
bookings: BookingsResponse,
Wrapper: FunctionComponent<{ children: JSX.Element }> = Fragment
) => {
jest
.spyOn(bookingsAPI, 'useBookings')
.mockReturnValue({ data: bookings } as QueryObserverResult<BookingsResponse, unknown>)

return render(
<Wrapper>{reactQueryProviderHOC(<EndedBookings enableBookingImprove={false} />)}</Wrapper>
<Wrapper>
{reactQueryProviderHOC(<EndedBookings enableBookingImprove={false} bookings={bookings} />)}
</Wrapper>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('<EndedBookings />', () => {
await measurePerformance(
reactQueryProviderHOC(
<AuthWrapper>
<EndedBookings enableBookingImprove={false} />
<EndedBookings enableBookingImprove={false} bookings={bookingsSnap} />
</AuthWrapper>
),
{
Expand Down

0 comments on commit e4d0cb4

Please sign in to comment.