2019-08-23 15:20:22 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
|
|
|
*
|
|
|
|
* This is free software, licensed under the GNU General Public License v3.
|
|
|
|
* See /LICENSE for more information.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* eslint import/export: "off" */
|
|
|
|
|
2019-10-30 17:06:53 +01:00
|
|
|
import React from "react";
|
|
|
|
import { UIDReset } from "react-uid";
|
2020-01-15 18:19:04 +01:00
|
|
|
import { StaticRouter } from "react-router-dom";
|
2019-10-30 17:06:53 +01:00
|
|
|
import { render } from "@testing-library/react";
|
|
|
|
import PropTypes from "prop-types";
|
|
|
|
|
2019-11-01 10:28:28 +01:00
|
|
|
import { AlertContextMock } from "./alertContextMock";
|
2019-08-23 15:20:22 +02:00
|
|
|
|
|
|
|
Wrapper.propTypes = {
|
|
|
|
children: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(PropTypes.node),
|
2019-10-30 17:06:53 +01:00
|
|
|
PropTypes.node,
|
|
|
|
]),
|
2019-08-23 15:20:22 +02:00
|
|
|
};
|
|
|
|
|
2019-10-30 17:06:53 +01:00
|
|
|
function Wrapper({ children }) {
|
|
|
|
return (
|
|
|
|
<AlertContextMock>
|
|
|
|
<StaticRouter>
|
2020-08-18 15:39:00 +02:00
|
|
|
<UIDReset>{children}</UIDReset>
|
2019-10-30 17:06:53 +01:00
|
|
|
</StaticRouter>
|
|
|
|
</AlertContextMock>
|
|
|
|
);
|
2019-08-23 15:20:22 +02:00
|
|
|
}
|
|
|
|
|
2020-08-18 15:39:00 +02:00
|
|
|
const customTestRender = (ui, options) =>
|
|
|
|
render(ui, { wrapper: Wrapper, ...options });
|
2019-08-23 15:20:22 +02:00
|
|
|
|
|
|
|
// re-export everything
|
2019-10-30 17:06:53 +01:00
|
|
|
export * from "@testing-library/react";
|
2019-08-23 15:20:22 +02:00
|
|
|
|
|
|
|
// override render method
|
2019-10-30 17:06:53 +01:00
|
|
|
export { customTestRender as render };
|