@@ -1200,4 +1200,91 @@ describe('"to satisfy" assertion', () => {
1200
1200
} ) ;
1201
1201
} ) ;
1202
1202
} ) ;
1203
+
1204
+ describe ( 'when used in a real world example' , ( ) => {
1205
+ it ( 'should produce a good satisfy diff' , ( ) => {
1206
+ const element = parseHtml (
1207
+ '<ul class="knockout-autocomplete menu scrollable floating-menu" style="left: 0px; top: 0px; bottom: auto; display: block">' +
1208
+ '<li class="selected" data-index="0">' +
1209
+ '<span class="before"></span>' +
1210
+ '<strong class="match">pr</strong>' +
1211
+ '<span class="after">ivate</span>' +
1212
+ '</li>' +
1213
+ '<li data-index="1">' +
1214
+ '<span class="before"></span>' +
1215
+ '<strong class="match">pr</strong>' +
1216
+ '<span class="after">otected</span>' +
1217
+ '</li>' +
1218
+ '</ul>'
1219
+ ) ;
1220
+
1221
+ expect (
1222
+ ( ) => {
1223
+ expect ( element , 'to satisfy' , {
1224
+ attributes : {
1225
+ style : { display : 'block' } ,
1226
+ class : [ 'knockout-autocomplete' , 'floating-menu' ]
1227
+ } ,
1228
+ children : [
1229
+ {
1230
+ attributes : { 'data-index' : '0' , class : 'selected' } ,
1231
+ children : [
1232
+ { attributes : { class : 'before' } , children : [ ] } ,
1233
+ { attributes : { class : 'match' } , children : [ 'pr' ] } ,
1234
+ { attributes : { class : 'after' } , children : [ 'ivate' ] }
1235
+ ]
1236
+ } ,
1237
+ {
1238
+ attributes : { 'data-index' : '1' , class : undefined } ,
1239
+ children : [
1240
+ { attributes : { class : 'before' } , children : [ ] } ,
1241
+ { attributes : { class : 'match' } , children : [ 'pr' ] } ,
1242
+ { attributes : { class : 'after' } , children : [ 'odtected' ] }
1243
+ ]
1244
+ }
1245
+ ]
1246
+ } ) ;
1247
+ } ,
1248
+ 'to throw an error satisfying to equal snapshot' ,
1249
+ expect . unindent `
1250
+ expected
1251
+ <ul class="knockout-autocomplete menu scrollable floating-menu" style="left: 0px; top: 0px; bottom: auto; display: block">
1252
+ <li class="selected" data-index="0">
1253
+ <span class="before"></span>
1254
+ <strong class="match">...</strong>
1255
+ <span class="after">...</span>
1256
+ </li>
1257
+ <li data-index="1">
1258
+ <span class="before"></span>
1259
+ <strong class="match">...</strong>
1260
+ <span class="after">...</span>
1261
+ </li>
1262
+ </ul>
1263
+ to satisfy
1264
+ {
1265
+ attributes: { style: { display: 'block' }, class: [ 'knockout-autocomplete', 'floating-menu' ] },
1266
+ children: [ { attributes: ..., children: ... }, { attributes: ..., children: ... } ]
1267
+ }
1268
+
1269
+ <ul class="knockout-autocomplete menu scrollable floating-menu" style="left: 0px; top: 0px; bottom: auto; display: block">
1270
+ <li class="selected" data-index="0">
1271
+ <span class="before"></span>
1272
+ <strong class="match">...</strong>
1273
+ <span class="after">...</span>
1274
+ </li>
1275
+ <li data-index="1">
1276
+ <span class="before"></span>
1277
+ <strong class="match">pr</strong>
1278
+ <span class="after">
1279
+ otected // should equal 'odtected'
1280
+ //
1281
+ // -otected
1282
+ // +odtected
1283
+ </span>
1284
+ </li>
1285
+ </ul>
1286
+ `
1287
+ ) ;
1288
+ } ) ;
1289
+ } ) ;
1203
1290
} ) ;
0 commit comments