UNPKG

@elastic/eui

Version:

Elastic UI Component Library

53 lines (48 loc) 2.91 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["queries"]; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ import { queries, render, screen, within } from '@testing-library/react'; import { EuiProvider } from '../../components'; import * as dataTestSubjQueries from './data_test_subj_queries'; /** * Custom render() fn with EuiProvider and query helpers * * @see https://testing-library.com/docs/react-testing-library/setup#custom-render * @see https://testing-library.com/docs/react-testing-library/setup#add-custom-queries */ var customRender = function customRender(ui) { var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var renderQueries = _ref.queries, options = _objectWithoutProperties(_ref, _excluded); return render(ui, _objectSpread({ queries: _objectSpread(_objectSpread(_objectSpread({}, queries), dataTestSubjQueries), renderQueries || {}), wrapper: EuiProvider }, options)); }; export { customRender as render }; /** * Custom screen util with EUI query helpers * * @see https://testing-library.com/docs/queries/about/#screen * @see https://github.com/testing-library/dom-testing-library/issues/516 */ var customScreen = _objectSpread(_objectSpread({}, screen), within(document.body, dataTestSubjQueries)); export { customScreen as screen }; /** * Custom within util with EUI query helpers * * @see https://testing-library.com/docs/dom-testing-library/api-within/ */ var customWithin = function customWithin(element) { return within(element, _objectSpread(_objectSpread({}, queries), dataTestSubjQueries)); }; export { customWithin as within };