@@ -308,30 +308,127 @@ describe('unexpected-dom', function () {
308
308
} ) ;
309
309
310
310
describe ( 'style attribute' , function ( ) {
311
- it ( 'should do string comparisons' , function ( ) {
312
- this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
311
+ describe ( 'lax comparison' , function ( ) {
312
+ it ( 'should do string comparisons' , function ( ) {
313
+ this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
313
314
314
- expect ( this . body . firstChild , 'to have attributes' , {
315
- style : 'color: red; background: blue'
315
+ expect ( this . body . firstChild , 'to have attributes' , {
316
+ style : 'color: red; background: blue'
317
+ } ) ;
316
318
} ) ;
317
- } ) ;
318
319
319
- it ( 'should do string comparisons in any order' , function ( ) {
320
- this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
320
+ it ( 'should do string comparisons in any order' , function ( ) {
321
+ this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
321
322
322
- expect ( this . body . firstChild , 'to have attributes' , {
323
- style : 'background: blue; color: red'
323
+ expect ( this . body . firstChild , 'to have attributes' , {
324
+ style : 'background: blue; color: red'
325
+ } ) ;
326
+ } ) ;
327
+
328
+ it ( 'should do string comparisons on partial values' , function ( ) {
329
+ this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
330
+
331
+ expect ( this . body . firstChild , 'to have attributes' , {
332
+ style : 'background: blue'
333
+ } ) ;
334
+ } ) ;
335
+
336
+ it ( 'should fail when styles are missing' , function ( ) {
337
+ this . body . innerHTML = '<i style="color: red"></i>' ;
338
+ var node = this . body . firstChild ;
339
+
340
+ expect ( function ( ) {
341
+ expect ( node , 'to have attributes' , {
342
+ style : 'background: blue'
343
+ } ) ;
344
+ } , 'to throw' , / t o h a v e a t t r i b u t e s \{ s t y l e : ' b a c k g r o u n d : b l u e ' \} / ) ;
345
+ } ) ;
346
+
347
+ it ( 'should do object comparisons' , function ( ) {
348
+ this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
349
+
350
+ expect ( this . body . firstChild , 'to have attributes' , {
351
+ style : {
352
+ color : 'red' ,
353
+ background : 'blue'
354
+ }
355
+ } ) ;
356
+ } ) ;
357
+
358
+ it ( 'should do partial object comparisons' , function ( ) {
359
+ this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
360
+
361
+ expect ( this . body . firstChild , 'to have attributes' , {
362
+ style : {
363
+ background : 'blue'
364
+ }
365
+ } ) ;
366
+ } ) ;
367
+
368
+ it ( 'should fail on missing partial object comparisons' , function ( ) {
369
+ this . body . innerHTML = '<i style="color: red"></i>' ;
370
+ var node = this . body . firstChild ;
371
+
372
+ expect ( function ( ) {
373
+ expect ( node , 'to have attributes' , {
374
+ style : {
375
+ background : 'blue'
376
+ }
377
+ } ) ;
378
+ } , 'to throw' , / t o h a v e a t t r i b u t e s \{ s t y l e : \{ b a c k g r o u n d : ' b l u e ' \} \} / ) ;
324
379
} ) ;
325
380
} ) ;
326
381
327
- it ( 'should do object comparisons' , function ( ) {
328
- this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
382
+ describe ( 'strict comparison' , function ( ) {
383
+ it ( 'should do string comparisons' , function ( ) {
384
+ this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
329
385
330
- expect ( this . body . firstChild , 'to have attributes' , {
331
- style : {
332
- color : 'red' ,
333
- background : 'blue'
334
- }
386
+ expect ( this . body . firstChild , 'to only have attributes' , {
387
+ style : 'color: red; background: blue'
388
+ } ) ;
389
+ } ) ;
390
+
391
+ it ( 'should do string comparisons in any order' , function ( ) {
392
+ this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
393
+
394
+ expect ( this . body . firstChild , 'to only have attributes' , {
395
+ style : 'background: blue; color: red'
396
+ } ) ;
397
+ } ) ;
398
+
399
+ it ( 'should fail when styles are missing' , function ( ) {
400
+ this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
401
+ var node = this . body . firstChild ;
402
+
403
+ expect ( function ( ) {
404
+ expect ( node , 'to only have attributes' , {
405
+ style : 'background: blue'
406
+ } ) ;
407
+ } , 'to throw' , / t o o n l y h a v e a t t r i b u t e s \{ s t y l e : ' b a c k g r o u n d : b l u e ' \} / ) ;
408
+ } ) ;
409
+
410
+ it ( 'should do object comparisons' , function ( ) {
411
+ this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
412
+
413
+ expect ( this . body . firstChild , 'to only have attributes' , {
414
+ style : {
415
+ color : 'red' ,
416
+ background : 'blue'
417
+ }
418
+ } ) ;
419
+ } ) ;
420
+
421
+ it ( 'should fail on missing partial object comparisons' , function ( ) {
422
+ this . body . innerHTML = '<i style="color: red; background: blue"></i>' ;
423
+ var node = this . body . firstChild ;
424
+
425
+ expect ( function ( ) {
426
+ expect ( node , 'to only have attributes' , {
427
+ style : {
428
+ background : 'blue'
429
+ }
430
+ } ) ;
431
+ } , 'to throw' , / t o o n l y h a v e a t t r i b u t e s \{ s t y l e : \{ b a c k g r o u n d : ' b l u e ' \} \} / ) ;
335
432
} ) ;
336
433
} ) ;
337
434
} ) ;
0 commit comments