@elastic/eui
Version:
Elastic UI Component Library
53 lines (48 loc) • 2.77 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["queries"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/*
* 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/provider';
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 };