Skip to content

Commit

Permalink
resolve warning : Warning: An update to TestComponent inside a test w…
Browse files Browse the repository at this point in the history
…as not wrapped in act(...).
  • Loading branch information
Ornella452 committed Oct 4, 2024
1 parent f40c2da commit 3dbfa2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ describe('candidature conseiller', () => {

// WHEN
const adresse = screen.getByLabelText('Votre lieu d’habitation * Saississez le nom ou le code postal de votre commune.');
fireEvent.change(adresse, { target: { value: 'par' } });
fireEvent.change(adresse, { target: { value: 'paris' } });

// THEN
const paris = await screen.findByRole('option', { name: '75001 Paris', hidden: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,15 @@ describe('candidature coordinateur', () => {
'1'
]
];

const { buildCoordinateurData } = renderHook(() => useApiAdmin.useApiAdmin()).result.current;
const { getGeoLocationFromAddress } = renderHook(() => useEntrepriseFinder()).result.current;
let geoLocation;

// //WHEN
const geoLocation = await getGeoLocationFromAddress('20 AVENUE DE SEGUR, 75007 PARIS');
// WHEN
// eslint-disable-next-line testing-library/no-unnecessary-act
await act(async () => {
geoLocation = await getGeoLocationFromAddress('20 AVENUE DE SEGUR, 75007 PARIS');
});
const result = await buildCoordinateurData(formData, geoLocation, '75107');

// THEN
Expand Down
7 changes: 5 additions & 2 deletions src/views/candidature-structure/CandidatureStructure.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,12 @@ describe('candidature structure', () => {

const { buildStructureData } = renderHook(() => useApiAdmin.useApiAdmin()).result.current;
const { getGeoLocationFromAddress } = renderHook(() => useEntrepriseFinder()).result.current;
let geoLocation;

// //WHEN
const geoLocation = await getGeoLocationFromAddress('20 AVENUE DE SEGUR, 75007 PARIS');
// WHEN
await act(async () => {
geoLocation = await getGeoLocationFromAddress('20 AVENUE DE SEGUR, 75007 PARIS');
});
const result = await buildStructureData(formData, geoLocation, '75107');

// THEN
Expand Down

0 comments on commit 3dbfa2f

Please sign in to comment.