From c63172eeebb48addb8ed60a973c6a55756b65af9 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 14 Apr 2022 12:21:34 +0200 Subject: [PATCH] test-utils: added tests to make sure route mounts are hidden Signed-off-by: Patrik Oldsberg --- .../test-utils/src/testUtils/appWrappers.test.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/test-utils/src/testUtils/appWrappers.test.tsx b/packages/test-utils/src/testUtils/appWrappers.test.tsx index 32ca3dfc02..c59f66aab5 100644 --- a/packages/test-utils/src/testUtils/appWrappers.test.tsx +++ b/packages/test-utils/src/testUtils/appWrappers.test.tsx @@ -159,4 +159,17 @@ describe('wrapInTestApp', () => { expect(rendered.getByText('Link S: /my-b-path/y/p')).toBeInTheDocument(); expect(rendered.getByText('Link E: /my-e-path/z')).toBeInTheDocument(); }); + + it('should not make route mounting elements visible during tests', async () => { + const routeRef = createRouteRef({ id: 'foo' }); + + const rendered = await renderInTestApp(foo, { + mountedRoutes: { '/foo': routeRef }, + }); + + const [root] = rendered.baseElement.children; + expect(root).toBeInTheDocument(); + expect(root.children.length).toBe(1); + expect(root.children[0].textContent).toBe('foo'); + }); });