|  | 
|  | 1 | +import '@testing-library/jest-dom' | 
|  | 2 | + | 
|  | 3 | +import {fireEvent, render} from '..' | 
|  | 4 | + | 
|  | 5 | +import TransitionSample from './components/TransitionSample' | 
|  | 6 | + | 
|  | 7 | +test('shows the text', async () => { | 
|  | 8 | +  // In Vue Test Utils, the <Transition> component is stubbed | 
|  | 9 | +  // by default, but javascript hooks are not supported. | 
|  | 10 | +  // If you want to test user interactions using javascript hooks, | 
|  | 11 | +  // you can turn off the <Transition> component stubbing | 
|  | 12 | +  // by setting global stubs transition to false. | 
|  | 13 | +  const {getByRole, findByText} = render(TransitionSample, { | 
|  | 14 | +    global: { | 
|  | 15 | +      stubs: { | 
|  | 16 | +        transition: false, | 
|  | 17 | +      }, | 
|  | 18 | +    }, | 
|  | 19 | +  }) | 
|  | 20 | + | 
|  | 21 | +  // Trigger fade in the text. | 
|  | 22 | +  await fireEvent.click(getByRole('button', {name: 'toggle'})) | 
|  | 23 | + | 
|  | 24 | +  // If setting transition stubs, this assertion is failed | 
|  | 25 | +  // because javascript hooks are not called and the text is not changed. | 
|  | 26 | +  expect(await findByText('Completed.')).toBeVisible() | 
|  | 27 | +}) | 
|  | 28 | + | 
|  | 29 | +test('hides the text', async () => { | 
|  | 30 | +  // If there is no need to use JavaScript Hooks, | 
|  | 31 | +  // you can render with the default settings. | 
|  | 32 | +  const {getByRole, queryByText} = render(TransitionSample) | 
|  | 33 | + | 
|  | 34 | +  // Trigger fade in the text. | 
|  | 35 | +  const toggleButton = getByRole('button', {name: 'toggle'}) | 
|  | 36 | +  await fireEvent.click(toggleButton) | 
|  | 37 | + | 
|  | 38 | +  // And trigger fade out the text. | 
|  | 39 | +  await fireEvent.click(toggleButton) | 
|  | 40 | + | 
|  | 41 | +  expect(queryByText('Now fade out...')).not.toBeVisible() | 
|  | 42 | +}) | 
0 commit comments