Skip to content

Instantly share code, notes, and snippets.

Test this out.

@Lukeghenco
Lukeghenco / debugMissingFieldHandlers.tsx
Created June 9, 2022 16:59 — forked from sibelius/debugMissingFieldHandlers.tsx
Special missing field handlers to debug what fields are missing when using renderPolicy partial
import { MissingFieldHandler } from 'relay-runtime/lib/store/RelayStoreTypes';
// missingFieldHandlers debug only
export const missingFieldHandlers: ReadonlyArray<MissingFieldHandler> = [
{
kind: 'scalar',
handle(
field,
record,
args,
## @tag :integration
To integrate this into an existing test just use the following:
1. The Entire "Test" file
<img width="360" alt="Screen Shot 2020-07-22 at 1 57 53 PM" src="https://user-images.githubusercontent.com/15013243/88229612-e2d9c400-cc25-11ea-8f65-cce1b0fe6e7f.png">
2. The Entire "Describe" block
<img width="693" alt="Screen Shot 2020-07-22 at 1 56 52 PM" src="https://user-images.githubusercontent.com/15013243/88229629-eb31ff00-cc25-11ea-8935-250a9a0ac808.png">
3. The Single "Test" block
@Lukeghenco
Lukeghenco / launch.md
Last active September 23, 2019 22:41 — forked from tmilewski/launch.md
@Lukeghenco
Lukeghenco / Enzyme-React-Testing-Libary-step-13.jsx
Last active October 23, 2019 07:27
Enzyme/React-Testing-Libary Step: 13
import React from 'react'
import { cleanup, render } from 'react-testing-library'
import TextAreaInput from './TextAreaInput'
const defaultProps = {
labelText: 'I am a label',
name: 'comment',
className: 'textarea-box',
labelClassName: 'small-heading',
handleOnChange: () => {}
@Lukeghenco
Lukeghenco / Enzyme-React-Testing-Libary-step-12.jsx
Last active January 16, 2019 01:02
Enzyme/React-Testing-Libary Step: 12
it('renders the value prop in the textarea as text', () => {
const value = 'This is a comment'
const { getByLabelText } = render(<TextAreaInput {…defaultProps} value={value} />)
const textareaInput = getByLabelText(defaultProps.labelText)
expect(textareaInput.value).toEqual(value)
})
@Lukeghenco
Lukeghenco / Enzyme-React-Testing-Libary-step-11.jsx
Last active January 16, 2019 01:02
Enzyme/React-Testing-Libary Step: 11
it('renders a placeholder correctly', () => {
const placeholderText = 'I am placeholder text'
const { getByLabelText } = render(<TextAreaInput {…defaultProps} placeholder={placeholderText} />)
const textareaInput = getByLabelText(defaultProps.labelText)
expect(textareaInput.placeholder).toEqual(placeholderText)
})
@Lukeghenco
Lukeghenco / Enzyme-React-Testing-Libary-step-10.jsx
Last active January 16, 2019 01:02
Enzyme/React-Testing-Libary Step: 10
it('does not have a disabled textarea input by default', () => {
const { getByLabelText } = render(<TextAreaInput {…defaultProps} />)
const textareaInput = getByLabelText(defaultProps.labelText)
expect(textareaInput.disabled).toEqual(false)
})
@Lukeghenco
Lukeghenco / Enzyme-React-Testing-Libary-step-9.jsx
Last active January 16, 2019 01:02
Enzyme/React-Testing-Libary Step: 9
it('has a disabled textarea if disabled prop is present', () => {
const { getByLabelText } = render(<TextAreaInput {…defaultProps} disabled />)
const textareaInput = getByLabelText(defaultProps.labelText)
expect(textareaInput.disabled).toEqual(true)
})
@Lukeghenco
Lukeghenco / Enzyme-React-Testing-Libary-step-8.jsx
Last active January 16, 2019 01:01
Enzyme/React-Testing-Libary Step: 8
it('will use the name prop to connect label to textarea tag if id prop is not present', () => {
const { getByLabelText, getByText } = render(<TextAreaInput {…defaultProps} id={null} />)
const label = getByText(defaultProps.labelText)
const textareaInput = getByLabelText(defaultProps.labelText)
expect(label.htmlFor).toEqual(defaultProps.name)
expect(textareaInput.id).toEqual(defaultProps.name)
})