Sha256: 2c277a83b80caf29aed95c97bd1be7ebe462f34a8a90296fdade5828ecf45b30

Contents?: true

Size: 1.09 KB

Versions: 17

Compression:

Stored size: 1.09 KB

Contents

/* This file provides the base for tests */

import React from 'react'
import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect'

// Accessbility
import { axe, toHaveNoViolations } from 'jest-axe'
expect.extend(toHaveNoViolations)

/*
  We can complicate this wrapper as needed.
  https://testing-library.com/docs/react-testing-library/setup
*/
// eslint-disable-next-line react/prop-types
const TestApp = ({ children }) => {
  return (
    <>
      { children }
    </>
  )
}

const customRender = (ui, options) =>
  render(ui, { wrapper: TestApp, ...options })

export * from '@testing-library/react'
export { customRender as render }

export const renderKit = (Kit, props = {}, newProps = {}) => {
  const kitProps = { ...props, ...newProps }
  render(<Kit {...kitProps} />)
  return screen.getByTestId(kitProps.data.testid)
}

export const ensureAccessible = async (Kit, props = {}, newProps = {}) => {
  const kitProps = { ...props, ...newProps }
  const render = () => <Kit {...kitProps} />
  const html = render()
  expect(await axe(html)).toHaveNoViolations()
}

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
playbook_ui-8.1.3 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.1.2 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.0.3 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.1.1 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.0.2 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.2.0.pre.alpha1 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.1.0 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.0.1 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.0.0 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.0.0.pre.alpha5 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.0.0.pre.alpha4 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-8.0.0.pre.alpha1 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-7.16.0.pre.alpha5 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-7.16.0.pre.alpha4 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-7.16.0.pre.alpha3 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-7.16.0.pre.alpha2 app/pb_kits/playbook/utilities/test-utils.js
playbook_ui-7.16.0.pre.alpha1 app/pb_kits/playbook/utilities/test-utils.js