@@ -7,7 +7,7 @@ var PlotlyInternal = require('@src/plotly');
7
7
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
8
8
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
9
9
var Plots = PlotlyInternal . Plots ;
10
-
10
+ var customMatchers = require ( '../assets/custom_matchers' ) ;
11
11
12
12
describe ( 'Test lib.js:' , function ( ) {
13
13
'use strict' ;
@@ -477,6 +477,10 @@ describe('Test lib.js:', function() {
477
477
} ) ;
478
478
479
479
describe ( 'expandObjectPaths' , function ( ) {
480
+ beforeAll ( function ( ) {
481
+ jasmine . addMatchers ( customMatchers ) ;
482
+ } ) ;
483
+
480
484
it ( 'returns the original object' , function ( ) {
481
485
var x = { } ;
482
486
expect ( Lib . expandObjectPaths ( x ) ) . toBe ( x ) ;
@@ -485,37 +489,37 @@ describe('Test lib.js:', function() {
485
489
it ( 'unpacks top-level paths' , function ( ) {
486
490
var input = { 'marker.color' : 'red' , 'marker.size' : [ 1 , 2 , 3 ] } ;
487
491
var expected = { marker : { color : 'red' , size : [ 1 , 2 , 3 ] } } ;
488
- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
492
+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
489
493
} ) ;
490
494
491
495
it ( 'unpacks recursively' , function ( ) {
492
496
var input = { 'marker.color' : { 'red.certainty' : 'definitely' } } ;
493
497
var expected = { marker : { color : { red : { certainty : 'definitely' } } } } ;
494
- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
498
+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
495
499
} ) ;
496
500
497
501
it ( 'unpacks deep paths' , function ( ) {
498
502
var input = { 'foo.bar.baz' : 'red' } ;
499
503
var expected = { foo : { bar : { baz : 'red' } } } ;
500
- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
504
+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
501
505
} ) ;
502
506
503
507
it ( 'unpacks non-top-level deep paths' , function ( ) {
504
508
var input = { color : { 'foo.bar.baz' : 'red' } } ;
505
509
var expected = { color : { foo : { bar : { baz : 'red' } } } } ;
506
- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
510
+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
507
511
} ) ;
508
512
509
513
it ( 'merges dotted properties into objects' , function ( ) {
510
514
var input = { marker : { color : 'red' } , 'marker.size' : 8 } ;
511
515
var expected = { marker : { color : 'red' , size : 8 } } ;
512
- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
516
+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
513
517
} ) ;
514
518
515
519
it ( 'merges objects into dotted properties' , function ( ) {
516
520
var input = { 'marker.size' : 8 , marker : { color : 'red' } } ;
517
521
var expected = { marker : { color : 'red' , size : 8 } } ;
518
- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
522
+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
519
523
} ) ;
520
524
521
525
it ( 'retains the identity of nested objects' , function ( ) {
@@ -541,49 +545,49 @@ describe('Test lib.js:', function() {
541
545
it ( 'expands bracketed array notation' , function ( ) {
542
546
var input = { 'marker[1]' : { color : 'red' } } ;
543
547
var expected = { marker : [ undefined , { color : 'red' } ] } ;
544
- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
548
+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
545
549
} ) ;
546
550
547
551
it ( 'expands nested arrays' , function ( ) {
548
552
var input = { 'marker[1].range[1]' : 5 } ;
549
553
var expected = { marker : [ undefined , { range : [ undefined , 5 ] } ] } ;
550
554
var computed = Lib . expandObjectPaths ( input ) ;
551
- expect ( computed ) . toEqual ( expected ) ;
555
+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
552
556
} ) ;
553
557
554
558
it ( 'expands bracketed array with more nested attributes' , function ( ) {
555
559
var input = { 'marker[1]' : { 'color.alpha' : 2 } } ;
556
560
var expected = { marker : [ undefined , { color : { alpha : 2 } } ] } ;
557
561
var computed = Lib . expandObjectPaths ( input ) ;
558
- expect ( computed ) . toEqual ( expected ) ;
562
+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
559
563
} ) ;
560
564
561
565
it ( 'expands bracketed array notation without further nesting' , function ( ) {
562
566
var input = { 'marker[1]' : 8 } ;
563
567
var expected = { marker : [ undefined , 8 ] } ;
564
568
var computed = Lib . expandObjectPaths ( input ) ;
565
- expect ( computed ) . toEqual ( expected ) ;
569
+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
566
570
} ) ;
567
571
568
572
it ( 'expands bracketed array notation with further nesting' , function ( ) {
569
573
var input = { 'marker[1].size' : 8 } ;
570
574
var expected = { marker : [ undefined , { size : 8 } ] } ;
571
575
var computed = Lib . expandObjectPaths ( input ) ;
572
- expect ( computed ) . toEqual ( expected ) ;
576
+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
573
577
} ) ;
574
578
575
579
it ( 'expands bracketed array notation with further nesting' , function ( ) {
576
580
var input = { 'marker[1].size.magnitude' : 8 } ;
577
581
var expected = { marker : [ undefined , { size : { magnitude : 8 } } ] } ;
578
582
var computed = Lib . expandObjectPaths ( input ) ;
579
- expect ( computed ) . toEqual ( expected ) ;
583
+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
580
584
} ) ;
581
585
582
586
it ( 'combines changes with single array nesting' , function ( ) {
583
587
var input = { 'marker[1].foo' : 5 , 'marker[0].foo' : 4 } ;
584
588
var expected = { marker : [ { foo : 4 } , { foo : 5 } ] } ;
585
589
var computed = Lib . expandObjectPaths ( input ) ;
586
- expect ( computed ) . toEqual ( expected ) ;
590
+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
587
591
} ) ;
588
592
589
593
// TODO: This test is unimplemented since it's a currently-unused corner case.
0 commit comments