@@ -92,6 +92,76 @@ describe('<FeelField>', function() {
92
92
} ) ;
93
93
94
94
95
+ it ( 'should trim whitespace on blur' , async function ( ) {
96
+
97
+ // given
98
+ const setValueSpy = sinon . spy ( ) ;
99
+
100
+ const result = createFeelField ( {
101
+ container,
102
+ setValue : setValueSpy
103
+ } ) ;
104
+
105
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
106
+
107
+ // when
108
+ input . focus ( ) ;
109
+ changeInput ( input , ' foo ' ) ;
110
+ input . blur ( ) ;
111
+
112
+ // then
113
+ expect ( setValueSpy ) . to . have . been . calledTwice ;
114
+ expect ( setValueSpy ) . to . have . been . calledWith ( 'foo' ) ;
115
+ } ) ;
116
+
117
+
118
+ it ( 'should call onBlur if provided' , async function ( ) {
119
+
120
+ // given
121
+ const setValueSpy = sinon . spy ( ) ;
122
+ const onBlurSpy = sinon . spy ( ) ;
123
+
124
+ const result = createFeelField ( {
125
+ container,
126
+ setValue : setValueSpy ,
127
+ onBlur : onBlurSpy
128
+ } ) ;
129
+
130
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
131
+
132
+ // when
133
+ input . focus ( ) ;
134
+ changeInput ( input , ' foo ' ) ;
135
+ input . blur ( ) ;
136
+
137
+ // then
138
+ expect ( onBlurSpy ) . to . have . been . calledOnce ;
139
+ } ) ;
140
+
141
+
142
+ it ( 'should not call setValue if the value is same' , async function ( ) {
143
+
144
+ // given
145
+ const setValueSpy = sinon . spy ( ) ;
146
+
147
+ const result = createFeelField ( {
148
+ container,
149
+ setValue : setValueSpy
150
+ } ) ;
151
+
152
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
153
+
154
+ // when
155
+ input . focus ( ) ;
156
+ changeInput ( input , '' ) ;
157
+ input . blur ( ) ;
158
+
159
+ // then
160
+ expect ( setValueSpy ) . to . not . have . been . called ;
161
+
162
+ } ) ;
163
+
164
+
95
165
describe ( '#isEdited' , function ( ) {
96
166
97
167
it ( 'should NOT be edited' , function ( ) {
@@ -1078,6 +1148,76 @@ describe('<FeelField>', function() {
1078
1148
} ) ;
1079
1149
1080
1150
1151
+ it ( 'should trim whitespace on blur' , async function ( ) {
1152
+
1153
+ // given
1154
+ const setValueSpy = sinon . spy ( ) ;
1155
+
1156
+ const result = createFeelTextArea ( {
1157
+ container,
1158
+ setValue : setValueSpy ,
1159
+ } ) ;
1160
+
1161
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
1162
+
1163
+ // when
1164
+ input . focus ( ) ;
1165
+ changeInput ( input , ' foo ' ) ;
1166
+ input . blur ( ) ;
1167
+
1168
+ // then
1169
+ expect ( setValueSpy ) . to . have . been . calledTwice ;
1170
+ expect ( setValueSpy ) . to . have . been . calledWith ( 'foo' ) ;
1171
+ } ) ;
1172
+
1173
+
1174
+ it ( 'should call onBlur if provided' , async function ( ) {
1175
+
1176
+ // given
1177
+ const setValueSpy = sinon . spy ( ) ;
1178
+ const onBlurSpy = sinon . spy ( ) ;
1179
+
1180
+ const result = createFeelTextArea ( {
1181
+ container,
1182
+ setValue : setValueSpy ,
1183
+ onBlur : onBlurSpy
1184
+ } ) ;
1185
+
1186
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
1187
+
1188
+ // when
1189
+ input . focus ( ) ;
1190
+ changeInput ( input , ' foo ' ) ;
1191
+ input . blur ( ) ;
1192
+
1193
+ // then
1194
+ expect ( onBlurSpy ) . to . have . been . calledOnce ;
1195
+ } ) ;
1196
+
1197
+
1198
+ it ( 'should not call setValue if the value is same' , async function ( ) {
1199
+
1200
+ // given
1201
+ const setValueSpy = sinon . spy ( ) ;
1202
+
1203
+ const result = createFeelTextArea ( {
1204
+ container,
1205
+ setValue : setValueSpy
1206
+ } ) ;
1207
+
1208
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
1209
+
1210
+ // when
1211
+ input . focus ( ) ;
1212
+ changeInput ( input , '' ) ;
1213
+ input . blur ( ) ;
1214
+
1215
+ // then
1216
+ expect ( setValueSpy ) . to . not . have . been . called ;
1217
+
1218
+ } ) ;
1219
+
1220
+
1081
1221
describe ( '#isEdited' , function ( ) {
1082
1222
1083
1223
it ( 'should NOT be edited' , function ( ) {
@@ -2622,6 +2762,7 @@ function createFeelField(options = {}, renderFn = render) {
2622
2762
container,
2623
2763
eventBus = new EventBus ( ) ,
2624
2764
onShow = noop ,
2765
+ onBlur = noop ,
2625
2766
errors = { } ,
2626
2767
variables,
2627
2768
openPopup = noop ,
@@ -2668,6 +2809,7 @@ function createFeelField(options = {}, renderFn = render) {
2668
2809
disabled = { disabled }
2669
2810
getValue = { getValue }
2670
2811
setValue = { setValue }
2812
+ onBlur = { onBlur }
2671
2813
debounce = { debounce }
2672
2814
validate = { validate }
2673
2815
feel = { feel }
0 commit comments