|
| 1 | +import { ReactTestInstance } from 'react-test-renderer'; |
| 2 | +import { RenderResult } from './render'; |
| 3 | + |
| 4 | +const SCREEN_ERROR = '`render` method has not been called'; |
| 5 | + |
| 6 | +const notImplemented = () => { |
| 7 | + throw new Error(SCREEN_ERROR); |
| 8 | +}; |
| 9 | + |
| 10 | +const notImplementedDebug = () => { |
| 11 | + throw new Error(SCREEN_ERROR); |
| 12 | +}; |
| 13 | +notImplementedDebug.shallow = notImplemented; |
| 14 | + |
| 15 | +const defaultScreen: RenderResult = { |
| 16 | + get container(): ReactTestInstance { |
| 17 | + throw new Error(SCREEN_ERROR); |
| 18 | + }, |
| 19 | + debug: notImplementedDebug, |
| 20 | + update: notImplemented, |
| 21 | + unmount: notImplemented, |
| 22 | + rerender: notImplemented, |
| 23 | + toJSON: notImplemented, |
| 24 | + getByLabelText: notImplemented, |
| 25 | + getAllByLabelText: notImplemented, |
| 26 | + queryByLabelText: notImplemented, |
| 27 | + queryAllByLabelText: notImplemented, |
| 28 | + findByLabelText: notImplemented, |
| 29 | + findAllByLabelText: notImplemented, |
| 30 | + getByA11yHint: notImplemented, |
| 31 | + getByHintText: notImplemented, |
| 32 | + getAllByA11yHint: notImplemented, |
| 33 | + getAllByHintText: notImplemented, |
| 34 | + queryByA11yHint: notImplemented, |
| 35 | + queryByHintText: notImplemented, |
| 36 | + queryAllByA11yHint: notImplemented, |
| 37 | + queryAllByHintText: notImplemented, |
| 38 | + findByA11yHint: notImplemented, |
| 39 | + findByHintText: notImplemented, |
| 40 | + findAllByA11yHint: notImplemented, |
| 41 | + findAllByHintText: notImplemented, |
| 42 | + getByRole: notImplemented, |
| 43 | + getAllByRole: notImplemented, |
| 44 | + queryByRole: notImplemented, |
| 45 | + queryAllByRole: notImplemented, |
| 46 | + findByRole: notImplemented, |
| 47 | + findAllByRole: notImplemented, |
| 48 | + getByA11yStates: notImplemented, |
| 49 | + getAllByA11yStates: notImplemented, |
| 50 | + queryByA11yStates: notImplemented, |
| 51 | + queryAllByA11yStates: notImplemented, |
| 52 | + findByA11yStates: notImplemented, |
| 53 | + findAllByA11yStates: notImplemented, |
| 54 | + getByA11yState: notImplemented, |
| 55 | + getAllByA11yState: notImplemented, |
| 56 | + queryByA11yState: notImplemented, |
| 57 | + queryAllByA11yState: notImplemented, |
| 58 | + findByA11yState: notImplemented, |
| 59 | + findAllByA11yState: notImplemented, |
| 60 | + getByA11yValue: notImplemented, |
| 61 | + getAllByA11yValue: notImplemented, |
| 62 | + queryByA11yValue: notImplemented, |
| 63 | + queryAllByA11yValue: notImplemented, |
| 64 | + findByA11yValue: notImplemented, |
| 65 | + findAllByA11yValue: notImplemented, |
| 66 | + UNSAFE_getByProps: notImplemented, |
| 67 | + UNSAFE_getAllByProps: notImplemented, |
| 68 | + UNSAFE_queryByProps: notImplemented, |
| 69 | + UNSAFE_queryAllByProps: notImplemented, |
| 70 | + UNSAFE_getByType: notImplemented, |
| 71 | + UNSAFE_getAllByType: notImplemented, |
| 72 | + UNSAFE_queryByType: notImplemented, |
| 73 | + UNSAFE_queryAllByType: notImplemented, |
| 74 | + getByPlaceholderText: notImplemented, |
| 75 | + getAllByPlaceholderText: notImplemented, |
| 76 | + queryByPlaceholderText: notImplemented, |
| 77 | + queryAllByPlaceholderText: notImplemented, |
| 78 | + findByPlaceholderText: notImplemented, |
| 79 | + findAllByPlaceholderText: notImplemented, |
| 80 | + getByDisplayValue: notImplemented, |
| 81 | + getAllByDisplayValue: notImplemented, |
| 82 | + queryByDisplayValue: notImplemented, |
| 83 | + queryAllByDisplayValue: notImplemented, |
| 84 | + findByDisplayValue: notImplemented, |
| 85 | + findAllByDisplayValue: notImplemented, |
| 86 | + getByTestId: notImplemented, |
| 87 | + getAllByTestId: notImplemented, |
| 88 | + queryByTestId: notImplemented, |
| 89 | + queryAllByTestId: notImplemented, |
| 90 | + findByTestId: notImplemented, |
| 91 | + findAllByTestId: notImplemented, |
| 92 | + getByText: notImplemented, |
| 93 | + getAllByText: notImplemented, |
| 94 | + queryByText: notImplemented, |
| 95 | + queryAllByText: notImplemented, |
| 96 | + findByText: notImplemented, |
| 97 | + findAllByText: notImplemented, |
| 98 | +}; |
| 99 | + |
| 100 | +export let screen: RenderResult = defaultScreen; |
| 101 | + |
| 102 | +export function setRenderResult(output: RenderResult) { |
| 103 | + screen = output; |
| 104 | +} |
| 105 | + |
| 106 | +export function clearRenderResult() { |
| 107 | + screen = defaultScreen; |
| 108 | +} |
0 commit comments