From 0bd19194236c6cc6b2493890154b0f855b08dedd Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Thu, 13 Dec 2018 10:12:30 +0100 Subject: [PATCH] Implement test render function for global theme and modes It renders the passed components with the global theme and modes provided through the `Root` core container component. This is necessary for all styled components that make use of any theme properties either simple values or functions. Associated epic: 38 GH-64 --- test/__utils__/index.js | 20 ++++++++++++++++++++ test/__utils__/renderWithTheme.jsx | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test/__utils__/index.js create mode 100644 test/__utils__/renderWithTheme.jsx diff --git a/test/__utils__/index.js b/test/__utils__/index.js new file mode 100644 index 00000000..a6d246b4 --- /dev/null +++ b/test/__utils__/index.js @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2018-present Arctic Ice Studio + * Copyright (C) 2018-present Sven Greb + * + * Project: Nord Docs + * Repository: https://github.com/arcticicestudio/nord-docs + * License: MIT + */ + +/** + * @file Provides test utility functions and classes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.3.0 + */ + +import renderWithTheme from "./renderWithTheme"; + +/* eslint-disable-next-line import/prefer-default-export */ +export { renderWithTheme }; diff --git a/test/__utils__/renderWithTheme.jsx b/test/__utils__/renderWithTheme.jsx new file mode 100644 index 00000000..db3128fb --- /dev/null +++ b/test/__utils__/renderWithTheme.jsx @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2018-present Arctic Ice Studio + * Copyright (C) 2018-present Sven Greb + * + * Project: Nord Docs + * Repository: https://github.com/arcticicestudio/nord-docs + * License: MIT + */ + +import React from "react"; +import { render } from "react-testing-library"; + +import Root from "containers/core/Root"; + +/** + * Renders the passed components with the global theme and modes provided through the `Root` core container component. + * + * @method renderWithTheme + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.3.0 + */ +const renderWithTheme = components => render({components}); + +export default renderWithTheme;