@@ -79,7 +79,78 @@ describe('<FeelEntry>', function() {
79
79
expect ( updateSpy ) . to . have . been . calledWith ( 'foo' ) ;
80
80
} ) ;
81
81
82
+ it ( 'should trim whitespace on blur' , async function ( ) {
83
+
84
+ // given
85
+ const setValueSpy = sinon . spy ( ) ;
86
+
87
+ const result = createFeelField ( {
88
+ container,
89
+ setValue : setValueSpy
90
+ } ) ;
91
+
92
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
93
+
94
+ // when
95
+ input . focus ( ) ;
96
+ changeInput ( input , ' foo ' ) ;
97
+ input . blur ( ) ;
98
+
99
+ // then
100
+ expect ( setValueSpy ) . to . have . been . calledTwice ;
101
+ expect ( setValueSpy ) . to . have . been . calledWith ( 'foo' ) ;
102
+ } ) ;
103
+
104
+
105
+ it ( 'should call onBlur if provided' , async function ( ) {
106
+
107
+ // given
108
+ const setValueSpy = sinon . spy ( ) ;
109
+ const onBlurSpy = sinon . spy ( ) ;
110
+
111
+ const result = createFeelField ( {
112
+ container,
113
+ setValue : setValueSpy ,
114
+ onBlur : onBlurSpy
115
+ } ) ;
116
+
117
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
118
+
119
+ // when
120
+ input . focus ( ) ;
121
+ changeInput ( input , ' foo ' ) ;
122
+ input . blur ( ) ;
123
+
124
+ // then
125
+ expect ( onBlurSpy ) . to . have . been . calledOnce ;
126
+ } ) ;
127
+
128
+
129
+ it ( 'should not call setValue if the value is same' , async function ( ) {
130
+
131
+ // given
132
+ const setValueSpy = sinon . spy ( ) ;
133
+
134
+ const result = createFeelField ( {
135
+ container,
136
+ setValue : setValueSpy
137
+ } ) ;
138
+
139
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
140
+
141
+ // when
142
+ input . focus ( ) ;
143
+ changeInput ( input , '' ) ;
144
+ input . blur ( ) ;
145
+
146
+ // then
147
+ expect ( setValueSpy ) . to . not . have . been . called ;
148
+
149
+ } ) ;
150
+
151
+
82
152
describe ( '#isEdited' , function ( ) {
153
+
83
154
it ( 'should NOT be edited' , function ( ) {
84
155
85
156
// given
@@ -1065,7 +1136,78 @@ describe('<FeelEntry>', function() {
1065
1136
expect ( updateSpy ) . to . have . been . calledWith ( 'foo' ) ;
1066
1137
} ) ;
1067
1138
1139
+ it ( 'should trim whitespace on blur' , async function ( ) {
1140
+
1141
+ // given
1142
+ const setValueSpy = sinon . spy ( ) ;
1143
+
1144
+ const result = createFeelTextArea ( {
1145
+ container,
1146
+ setValue : setValueSpy ,
1147
+ } ) ;
1148
+
1149
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
1150
+
1151
+ // when
1152
+ input . focus ( ) ;
1153
+ changeInput ( input , ' foo ' ) ;
1154
+ input . blur ( ) ;
1155
+
1156
+ // then
1157
+ expect ( setValueSpy ) . to . have . been . calledTwice ;
1158
+ expect ( setValueSpy ) . to . have . been . calledWith ( 'foo' ) ;
1159
+ } ) ;
1160
+
1161
+
1162
+ it ( 'should call onBlur if provided' , async function ( ) {
1163
+
1164
+ // given
1165
+ const setValueSpy = sinon . spy ( ) ;
1166
+ const onBlurSpy = sinon . spy ( ) ;
1167
+
1168
+ const result = createFeelTextArea ( {
1169
+ container,
1170
+ setValue : setValueSpy ,
1171
+ onBlur : onBlurSpy
1172
+ } ) ;
1173
+
1174
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
1175
+
1176
+ // when
1177
+ input . focus ( ) ;
1178
+ changeInput ( input , ' foo ' ) ;
1179
+ input . blur ( ) ;
1180
+
1181
+ // then
1182
+ expect ( onBlurSpy ) . to . have . been . calledOnce ;
1183
+ } ) ;
1184
+
1185
+
1186
+ it ( 'should not call setValue if the value is same' , async function ( ) {
1187
+
1188
+ // given
1189
+ const setValueSpy = sinon . spy ( ) ;
1190
+
1191
+ const result = createFeelTextArea ( {
1192
+ container,
1193
+ setValue : setValueSpy
1194
+ } ) ;
1195
+
1196
+ const input = domQuery ( '.bio-properties-panel-input' , result . container ) ;
1197
+
1198
+ // when
1199
+ input . focus ( ) ;
1200
+ changeInput ( input , '' ) ;
1201
+ input . blur ( ) ;
1202
+
1203
+ // then
1204
+ expect ( setValueSpy ) . to . not . have . been . called ;
1205
+
1206
+ } ) ;
1207
+
1208
+
1068
1209
describe ( '#isEdited' , function ( ) {
1210
+
1069
1211
it ( 'should NOT be edited' , function ( ) {
1070
1212
1071
1213
// given
@@ -2692,6 +2834,7 @@ function createFeelField(options = {}, renderFn = render) {
2692
2834
container,
2693
2835
eventBus = new EventBus ( ) ,
2694
2836
onShow = noop ,
2837
+ onBlur = noop ,
2695
2838
errors = { } ,
2696
2839
variables,
2697
2840
Component = FeelField ,
@@ -2728,6 +2871,7 @@ function createFeelField(options = {}, renderFn = render) {
2728
2871
disabled = { disabled }
2729
2872
getValue = { getValue }
2730
2873
setValue = { setValue }
2874
+ onBlur = { onBlur }
2731
2875
debounce = { debounce }
2732
2876
validate = { validate }
2733
2877
feel = { feel }
0 commit comments