-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(plugins): allow setting vuex/router and custom plugins (#200)
* Do not mount component again on rerender * fix(plugins): allow setting custom plugin and vuex/router * Simplify setting logic
- Loading branch information
Showing
3 changed files
with
57 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import '@testing-library/jest-dom' | ||
import ElementPlus from 'element-plus' | ||
import userEvent from '@testing-library/user-event' | ||
import {defineComponent} from 'vue' | ||
import {render, screen, fireEvent, waitFor} from '..' | ||
import {store} from './components/Store/store' | ||
|
||
test('can set global options and custom options such as a store', async () => { | ||
const ComponentWithStore = defineComponent({ | ||
template: ` | ||
<el-popover trigger="hover" content="this is content"> | ||
<template #reference> | ||
<el-button @click="$store.dispatch('increment')"> | ||
Hover to activate | ||
</el-button> | ||
</template> | ||
</el-popover> | ||
<span data-testid="count-value">{{ $store.state.count }}</span> | ||
<directive /> | ||
`, | ||
}) | ||
|
||
const DirectiveStub = { | ||
template: '<p>Search now</p>', | ||
} | ||
|
||
render(ComponentWithStore, { | ||
store, | ||
global: { | ||
plugins: [ElementPlus], | ||
stubs: { | ||
Directive: DirectiveStub, | ||
}, | ||
}, | ||
}) | ||
|
||
expect(screen.getByText('Search now')).toBeInTheDocument() | ||
|
||
const button = screen.getByText('Hover to activate') | ||
userEvent.hover(button) | ||
|
||
await waitFor(() => expect(screen.getByText('this is content')).toBeVisible()) | ||
|
||
expect(screen.getByTestId('count-value')).toHaveTextContent('0') | ||
|
||
await fireEvent.click(button) | ||
|
||
expect(screen.getByTestId('count-value')).toHaveTextContent('1') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters