Skip to content

Commit 80d574c

Browse files
committed
Simplify setting logic
1 parent 53e73ac commit 80d574c

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
"dependencies": {
5050
"@babel/runtime": "^7.12.1",
5151
"@testing-library/dom": "^7.28.1",
52-
"@vue/test-utils": "^2.0.0-beta.12",
53-
"lodash.merge": "^4.6.2"
52+
"@vue/test-utils": "^2.0.0-beta.12"
5453
},
5554
"devDependencies": {
5655
"@apollo/client": "3.3.6",
@@ -70,6 +69,7 @@
7069
"isomorphic-unfetch": "^3.1.0",
7170
"jest-serializer-vue": "^2.0.2",
7271
"kcd-scripts": "^7.5.1",
72+
"lodash.merge": "^4.6.2",
7373
"msw": "^0.21.3",
7474
"typescript": "^4.1.2",
7575
"vee-validate": "^4.0.2",

src/__tests__/plugins.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {defineComponent} from 'vue'
55
import {render, screen, fireEvent, waitFor} from '..'
66
import {store} from './components/Store/store'
77

8-
test('setting a plugin + a custom option such as store sets both plugins', async () => {
8+
test('can set global options and custom options such as a store', async () => {
99
const ComponentWithStore = defineComponent({
1010
template: `
1111
<el-popover trigger="hover" content="this is content">
@@ -16,16 +16,26 @@ test('setting a plugin + a custom option such as store sets both plugins', async
1616
</template>
1717
</el-popover>
1818
<span data-testid="count-value">{{ $store.state.count }}</span>
19+
<directive />
1920
`,
2021
})
2122

23+
const DirectiveStub = {
24+
template: '<p>Search now</p>',
25+
}
26+
2227
render(ComponentWithStore, {
2328
store,
2429
global: {
2530
plugins: [ElementPlus],
31+
stubs: {
32+
Directive: DirectiveStub,
33+
},
2634
},
2735
})
2836

37+
expect(screen.getByText('Search now')).toBeInTheDocument()
38+
2939
const button = screen.getByText('Hover to activate')
3040
userEvent.hover(button)
3141

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ function render(
4141
}
4242

4343
const wrapper = mount(Component, {
44-
attachTo: container,
45-
global: {plugins},
4644
...mountOptions,
45+
attachTo: container,
46+
global: {...mountOptions.global, plugins},
4747
})
4848

4949
// this removes the additional "data-v-app" div node from VTU:

0 commit comments

Comments
 (0)