File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
packages/dropdown/tests/unit Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,15 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'
22
33import Dropdown from '@p/dropdown/src/index.vue'
44
5+ document . body . innerHTML = `
6+ <div>
7+ <button id="btn1">btn 1 </button>
8+ <button id="btn2">btn 2 </button>
9+ <button id="btn3">btn 3 </button>
10+ <a href="#" id="test-link">test</a>
11+ </div>
12+ `
13+
514const localVue = createLocalVue ( )
615
716describe ( 'Dropdown' , ( ) => {
@@ -96,6 +105,18 @@ describe('Dropdown', () => {
96105
97106 expect ( lastItem . element ) . toBe ( document . activeElement )
98107 } )
108+
109+ it ( 'closes the menu if click happens outside of it' , async ( ) => {
110+ button . trigger ( 'keydown.down' )
111+
112+ await wrapper . vm . $nextTick ( )
113+
114+ document . getElementById ( 'test-link' ) . click ( )
115+
116+ await wrapper . vm . $nextTick ( )
117+
118+ expect ( wrapper . vm . $refs . menu ) . toBeUndefined ( )
119+ } )
99120 } )
100121
101122 describe ( 'Menu toggle button' , ( ) => {
You can’t perform that action at this time.
0 commit comments