| 
1 | 1 | import ElementPlus from 'element-plus'  | 
2 | 2 | import {defineComponent} from 'vue'  | 
3 |  | -import userEvent from '@testing-library/user-event'  | 
4 | 3 | import '@testing-library/jest-dom'  | 
5 |  | -import {render, screen,waitFor} from '..'  | 
 | 4 | +import {render, screen} from '..'  | 
6 | 5 | 
 
  | 
7 | 6 | const Component = defineComponent({  | 
8 | 7 |  template: `  | 
9 |  | - <el-popover trigger="click" content="this is content">  | 
10 |  | - <template #reference>  | 
11 |  | - <el-button>Click to activate</el-button>  | 
12 |  | - </template>  | 
13 |  | - </el-popover>  | 
14 |  | - `,  | 
 | 8 | + <el-alert title="success alert" type="success" />`,  | 
15 | 9 | })  | 
16 | 10 | 
 
  | 
17 |  | -test('Stubs out a component', async () => {  | 
 | 11 | +test('Renders component from third-party library', async () => {  | 
18 | 12 |  render(Component, {  | 
19 | 13 |  global: {  | 
20 | 14 |  plugins: [ElementPlus],  | 
21 | 15 |  },  | 
22 | 16 |  })  | 
23 | 17 | 
 
  | 
24 |  | - const button = screen.getByRole('button')  | 
25 |  | - const getContent = () => screen.getByText('this is content')  | 
26 |  | - | 
27 |  | - expect(getContent()).toBeInTheDocument()  | 
28 |  | - expect(getContent()).not.toBeVisible()  | 
29 |  | - | 
30 |  | - userEvent.click(button)  | 
31 |  | - | 
32 |  | - await waitFor(() => expect(getContent()).toBeVisible())  | 
33 |  | - | 
34 |  | - userEvent.click(button)  | 
35 |  | - | 
36 |  | - await waitFor(() => expect(getContent()).not.toBeVisible())  | 
 | 18 | + expect(screen.getByRole('alert')).toHaveTextContent('success alert')  | 
37 | 19 | })  | 
0 commit comments