@@ -32,7 +32,11 @@ describe('Mentions', () => {
32
32
33
33
it ( 'not lose focus if click on dropdown' , ( ) => {
34
34
const onBlur = jest . fn ( ) ;
35
- const wrapper = createMentions ( { autoFocus : true , defaultValue : '@' , onBlur } ) ;
35
+ const wrapper = createMentions ( {
36
+ autoFocus : true ,
37
+ defaultValue : '@' ,
38
+ onBlur,
39
+ } ) ;
36
40
37
41
// Inject to trigger measure
38
42
wrapper . instance ( ) . startMeasure ( 'b' , '@' , 1 ) ;
@@ -45,22 +49,22 @@ describe('Mentions', () => {
45
49
wrapper . find ( 'textarea' ) . simulate ( 'focus' ) ; // This is not good but code focus not work in simulate
46
50
jest . runAllTimers ( ) ;
47
51
48
- expect ( onBlur ) . not . toBeCalled ( ) ;
52
+ expect ( onBlur ) . not . toHaveBeenCalled ( ) ;
49
53
} ) ;
50
54
51
55
it ( 'focus' , ( ) => {
52
56
const onFocus = jest . fn ( ) ;
53
57
const wrapper = createMentions ( { onFocus } ) ;
54
58
wrapper . find ( 'textarea' ) . simulate ( 'focus' ) ;
55
- expect ( onFocus ) . toBeCalled ( ) ;
59
+ expect ( onFocus ) . toHaveBeenCalled ( ) ;
56
60
} ) ;
57
61
58
62
it ( 'blur' , ( ) => {
59
63
const onBlur = jest . fn ( ) ;
60
64
const wrapper = createMentions ( { onBlur } ) ;
61
65
wrapper . find ( 'textarea' ) . simulate ( 'blur' ) ;
62
66
jest . runAllTimers ( ) ;
63
- expect ( onBlur ) . toBeCalled ( ) ;
67
+ expect ( onBlur ) . toHaveBeenCalled ( ) ;
64
68
} ) ;
65
69
66
70
it ( 'focus() & blur()' , ( ) => {
@@ -69,7 +73,9 @@ describe('Mentions', () => {
69
73
expect ( document . activeElement ) . toBe ( wrapper . find ( 'textarea' ) . instance ( ) ) ;
70
74
71
75
wrapper . instance ( ) . blur ( ) ;
72
- expect ( document . activeElement ) . not . toBe ( wrapper . find ( 'textarea' ) . instance ( ) ) ;
76
+ expect ( document . activeElement ) . not . toBe (
77
+ wrapper . find ( 'textarea' ) . instance ( ) ,
78
+ ) ;
73
79
} ) ;
74
80
} ) ;
75
81
@@ -85,6 +91,9 @@ describe('Mentions', () => {
85
91
86
92
wrapper . setProps ( { value : 'cat' } ) ;
87
93
expect ( wrapper . find ( 'textarea' ) . props ( ) . value ) . toBe ( 'cat' ) ;
94
+
95
+ wrapper . setProps ( { value : undefined } ) ;
96
+ expect ( wrapper . find ( 'textarea' ) . props ( ) . value ) . toBe ( '' ) ;
88
97
} ) ;
89
98
90
99
it ( 'onChange' , ( ) => {
@@ -93,7 +102,7 @@ describe('Mentions', () => {
93
102
wrapper . find ( 'textarea' ) . simulate ( 'change' , {
94
103
target : { value : 'bamboo' } ,
95
104
} ) ;
96
- expect ( onChange ) . toBeCalledWith ( 'bamboo' ) ;
105
+ expect ( onChange ) . toHaveBeenCalledWith ( 'bamboo' ) ;
97
106
} ) ;
98
107
} ) ;
99
108
@@ -105,7 +114,9 @@ describe('Mentions', () => {
105
114
} ) ;
106
115
107
116
it ( 'function' , ( ) => {
108
- const wrapper = createMentions ( { filterOption : ( _ , { value } ) => value . includes ( 'a' ) } ) ;
117
+ const wrapper = createMentions ( {
118
+ filterOption : ( _ , { value } ) => value . includes ( 'a' ) ,
119
+ } ) ;
109
120
simulateInput ( wrapper , '@notExist' ) ;
110
121
expect ( wrapper . find ( 'DropdownMenu' ) . props ( ) . options . length ) . toBe ( 2 ) ;
111
122
} ) ;
0 commit comments