Skip to content

Commit

Permalink
(PC-33768)[PRO] test: Adds tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jclery-pass committed Jan 21, 2025
1 parent 7f256c0 commit 7b465a8
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {

import { api } from 'apiClient/api'
import { OfferStatus } from 'apiClient/v1'
import { listOffersOfferFactory } from 'commons/utils/factories/individualApiFactories'
import {
defaultGetOffererResponseModel,
defaultGetOffererVenueResponseModel,
listOffersOfferFactory,
} from 'commons/utils/factories/individualApiFactories'
import {
renderWithProviders,
RenderWithProvidersOptions,
Expand All @@ -26,12 +30,20 @@ const renderOnboardingOfferIndividual = (
vi.mock('apiClient/api', () => ({
api: {
listOffers: vi.fn(),
getOfferer: vi.fn(),
},
}))

describe('<OnboardingOfferIndividual />', () => {
beforeEach(() => {
vi.spyOn(api, 'listOffers').mockResolvedValue([])
vi.spyOn(api, 'getOfferer').mockResolvedValue({
...defaultGetOffererResponseModel,
id: 42,
managedVenues: [
{ ...defaultGetOffererVenueResponseModel, isPermanent: true, id: 1337 },
],
})
})

it('should propose how to create the 1st offer', async () => {
Expand All @@ -50,6 +62,22 @@ describe('<OnboardingOfferIndividual />', () => {
expect(links).toHaveLength(2)
})

it('should redirect to venue settings if user chooses "automatiquement"', async () => {
renderOnboardingOfferIndividual({
storeOverrides: {
offerer: { selectedOffererId: 42, offererNames: [] },
},
})

await waitForElementToBeRemoved(() => screen.queryByTestId('spinner'))

expect(api.getOfferer).toHaveBeenCalledOnce()

expect(
await screen.findByRole('link', { name: /Automatiquement/ })
).toHaveAttribute('href', '/structures/42/lieux/1337/parametres')
})

it('should not display drafts if listOffers returns an empty array', async () => {
renderOnboardingOfferIndividual()

Expand Down

0 comments on commit 7b465a8

Please sign in to comment.