use renderInTestApp

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-09-14 21:22:11 +02:00
parent 8a6a66f621
commit ab6474579f
72 changed files with 2587 additions and 2982 deletions
+8 -13
View File
@@ -15,8 +15,7 @@
*/
import React from 'react';
import { wrapInTestApp } from '@backstage/test-utils';
import { act, render } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import { useNavigateToQuery } from './util';
import { rootRouteRef } from '../plugin';
@@ -35,18 +34,14 @@ describe('util', () => {
return <div>test</div>;
};
await act(async () => {
await render(
wrapInTestApp(<MyComponent />, {
mountedRoutes: {
'/search': rootRouteRef,
},
}),
);
expect(navigate).toHaveBeenCalledTimes(1);
expect(navigate).toHaveBeenCalledWith('/search?query=test');
await renderInTestApp(<MyComponent />, {
mountedRoutes: {
'/search': rootRouteRef,
},
});
expect(navigate).toHaveBeenCalled();
expect(navigate).toHaveBeenCalledWith('/search?query=test');
});
});
});