File tree Expand file tree Collapse file tree 6 files changed +169
-0
lines changed Expand file tree Collapse file tree 6 files changed +169
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { mount } from '@vue/test-utils'
2
+ import Dropdown from '..'
3
+
4
+ describe ( 'DropdownButton' , ( ) => {
5
+ it ( 'pass appropriate props to Dropdown' , ( ) => {
6
+ const props = {
7
+ align : {
8
+ offset : [ 10 , 20 ] ,
9
+ } ,
10
+ disabled : false ,
11
+ trigger : [ 'hover' ] ,
12
+ visible : true ,
13
+ }
14
+
15
+ const wrapper = mount ( Dropdown . Button , {
16
+ propsData : props ,
17
+ listeners : {
18
+ visibleChange : ( ) => { } ,
19
+ } ,
20
+ } )
21
+ const dropdownProps = wrapper . find ( { name : 'ADropdown' } ) . props ( )
22
+
23
+ Object . keys ( props ) . forEach ( ( key ) => {
24
+ expect ( dropdownProps [ key ] ) . toBe ( props [ key ] )
25
+ } )
26
+ } )
27
+
28
+ it ( 'don\'t pass visible to Dropdown if it\'s not exits' , ( ) => {
29
+ const wrapper = mount ( Dropdown . Button )
30
+ const dropdownProps = wrapper . find ( { name : 'ADropdown' } ) . props ( )
31
+
32
+ expect ( 'visible' in dropdownProps ) . toBe ( false )
33
+ } )
34
+ } )
Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [` Popover should show overlay when trigger is clicked 1` ] = `
4
+ <div class = " ant-popover-content" >
5
+ <div class = " ant-popover-arrow" ></div >
6
+ <div class = " ant-popover-inner" >
7
+ <div >
8
+ <div class = " ant-popover-title" >code</div >
9
+ <div class = " ant-popover-inner-content" >console.log('hello world')</div >
10
+ </div >
11
+ </div >
12
+ </div >
13
+ ` ;
14
+
15
+ exports [` Popover should show overlay when trigger is clicked 2` ] = `
16
+ <div class = " ant-popover-content" >
17
+ <div class = " ant-popover-arrow" ></div >
18
+ <div class = " ant-popover-inner" >
19
+ <div >
20
+ <div class = " ant-popover-title" >code</div >
21
+ <div class = " ant-popover-inner-content" >console.log('hello world')</div >
22
+ </div >
23
+ </div >
24
+ </div >
25
+ ` ;
Original file line number Diff line number Diff line change
1
+ import { mount } from '@vue/test-utils'
2
+ import { asyncExpect } from '@/tests/utils'
3
+ import Popover from '..'
4
+
5
+ describe ( 'Popover' , ( ) => {
6
+ it ( 'should show overlay when trigger is clicked' , async ( ) => {
7
+ const popover = mount ( {
8
+ render ( ) {
9
+ return (
10
+ < Popover ref = 'popover' content = "console.log('hello world')" title = 'code' trigger = 'click' >
11
+ < span > show me your code</ span >
12
+ </ Popover >
13
+ )
14
+ } ,
15
+ } , { sync : false } )
16
+ await asyncExpect ( ( ) => {
17
+ expect ( popover . vm . $refs . popover . getPopupDomNode ( ) ) . toBe ( null )
18
+
19
+ popover . find ( 'span' ) . trigger ( 'click' )
20
+ } , 0 )
21
+ let popup = null
22
+ await asyncExpect ( ( ) => {
23
+ popup = popover . vm . $refs . popover . getPopupDomNode ( )
24
+ expect ( popup ) . not . toBe ( null )
25
+ expect ( popup . className ) . toContain ( 'ant-popover-placement-top' )
26
+ } , 1000 )
27
+ await asyncExpect ( ( ) => {
28
+ expect ( popup . innerHTML ) . toMatchSnapshot ( )
29
+ expect ( popup . innerHTML ) . toMatchSnapshot ( )
30
+ } )
31
+ await asyncExpect ( ( ) => {
32
+
33
+ } )
34
+ } )
35
+ } )
Original file line number Diff line number Diff line change
1
+ import { mount } from '@vue/test-utils'
2
+ import { asyncExpect } from '@/tests/utils'
3
+ import Tag from '..'
4
+
5
+ describe ( 'Tag' , ( ) => {
6
+ beforeAll ( ( ) => {
7
+ jest . useFakeTimers ( )
8
+ } )
9
+
10
+ afterAll ( ( ) => {
11
+ jest . useRealTimers ( )
12
+ } )
13
+
14
+ it ( 'should be closable' , ( ) => {
15
+ const onClose = jest . fn ( )
16
+ const wrapper = mount ( {
17
+ render ( ) {
18
+ return < Tag closable onClose = { onClose } />
19
+ } ,
20
+ } )
21
+ expect ( wrapper . findAll ( '.anticon-cross' ) . length ) . toBe ( 1 )
22
+ expect ( wrapper . findAll ( '.ant-tag' ) . length ) . toBe ( 1 )
23
+ wrapper . find ( '.anticon-cross' ) . trigger ( 'click' )
24
+ expect ( onClose ) . toBeCalled ( )
25
+ jest . runAllTimers ( )
26
+ expect ( wrapper . findAll ( '.ant-tag' ) . length ) . toBe ( 0 )
27
+ } )
28
+
29
+ it ( 'should not be closed when prevent default' , ( ) => {
30
+ const onClose = ( e ) => {
31
+ e . preventDefault ( )
32
+ }
33
+ const wrapper = mount ( {
34
+ render ( ) {
35
+ return < Tag closable onClose = { onClose } />
36
+ } ,
37
+ } )
38
+ expect ( wrapper . findAll ( '.anticon-cross' ) . length ) . toBe ( 1 )
39
+ expect ( wrapper . findAll ( '.ant-tag' ) . length ) . toBe ( 1 )
40
+ wrapper . find ( '.anticon-cross' ) . trigger ( 'click' )
41
+ jest . runAllTimers ( )
42
+ expect ( wrapper . findAll ( '.ant-tag' ) . length ) . toBe ( 1 )
43
+ } )
44
+ } )
Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [` TimePicker renders addon correctly 1` ] = `
4
+ <div class = " ant-time-picker-panel-addon" >
5
+ <button >Ok</button >
6
+ </div >
7
+ ` ;
Original file line number Diff line number Diff line change
1
+ import { mount } from '@vue/test-utils'
2
+ import { asyncExpect } from '@/tests/utils'
3
+ import VcTimePicker from '../../vc-time-picker/TimePicker'
4
+ import TimePicker from '..'
5
+ import focusTest from '../../../tests/shared/focusTest'
6
+
7
+ describe ( 'TimePicker' , ( ) => {
8
+ focusTest ( TimePicker )
9
+
10
+ it ( 'renders addon correctly' , ( ) => {
11
+ const wrapper = mount ( {
12
+ render ( ) {
13
+ return < TimePicker addon = { ( ) => ( < button > Ok</ button > ) } />
14
+ } ,
15
+ } )
16
+ const vcTimePicker = wrapper . find ( { name : VcTimePicker . name } )
17
+ const addonWrapper = mount ( {
18
+ render ( ) {
19
+ return vcTimePicker . vm . $slots . addon [ 0 ]
20
+ } ,
21
+ } )
22
+ expect ( addonWrapper . html ( ) ) . toMatchSnapshot ( )
23
+ } )
24
+ } )
You can’t perform that action at this time.
0 commit comments