@@ -7,7 +7,7 @@ var PlotlyInternal = require('@src/plotly');
77var createGraphDiv = require ( '../assets/create_graph_div' ) ;
88var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
99var Plots = PlotlyInternal . Plots ;
10-
10+ var customMatchers = require ( '../assets/custom_matchers' ) ;
1111
1212describe ( 'Test lib.js:' , function ( ) {
1313 'use strict' ;
@@ -477,6 +477,10 @@ describe('Test lib.js:', function() {
477477 } ) ;
478478
479479 describe ( 'expandObjectPaths' , function ( ) {
480+ beforeAll ( function ( ) {
481+ jasmine . addMatchers ( customMatchers ) ;
482+ } ) ;
483+
480484 it ( 'returns the original object' , function ( ) {
481485 var x = { } ;
482486 expect ( Lib . expandObjectPaths ( x ) ) . toBe ( x ) ;
@@ -485,37 +489,37 @@ describe('Test lib.js:', function() {
485489 it ( 'unpacks top-level paths' , function ( ) {
486490 var input = { 'marker.color' : 'red' , 'marker.size' : [ 1 , 2 , 3 ] } ;
487491 var expected = { marker : { color : 'red' , size : [ 1 , 2 , 3 ] } } ;
488- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
492+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
489493 } ) ;
490494
491495 it ( 'unpacks recursively' , function ( ) {
492496 var input = { 'marker.color' : { 'red.certainty' : 'definitely' } } ;
493497 var expected = { marker : { color : { red : { certainty : 'definitely' } } } } ;
494- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
498+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
495499 } ) ;
496500
497501 it ( 'unpacks deep paths' , function ( ) {
498502 var input = { 'foo.bar.baz' : 'red' } ;
499503 var expected = { foo : { bar : { baz : 'red' } } } ;
500- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
504+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
501505 } ) ;
502506
503507 it ( 'unpacks non-top-level deep paths' , function ( ) {
504508 var input = { color : { 'foo.bar.baz' : 'red' } } ;
505509 var expected = { color : { foo : { bar : { baz : 'red' } } } } ;
506- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
510+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
507511 } ) ;
508512
509513 it ( 'merges dotted properties into objects' , function ( ) {
510514 var input = { marker : { color : 'red' } , 'marker.size' : 8 } ;
511515 var expected = { marker : { color : 'red' , size : 8 } } ;
512- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
516+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
513517 } ) ;
514518
515519 it ( 'merges objects into dotted properties' , function ( ) {
516520 var input = { 'marker.size' : 8 , marker : { color : 'red' } } ;
517521 var expected = { marker : { color : 'red' , size : 8 } } ;
518- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
522+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
519523 } ) ;
520524
521525 it ( 'retains the identity of nested objects' , function ( ) {
@@ -541,49 +545,49 @@ describe('Test lib.js:', function() {
541545 it ( 'expands bracketed array notation' , function ( ) {
542546 var input = { 'marker[1]' : { color : 'red' } } ;
543547 var expected = { marker : [ undefined , { color : 'red' } ] } ;
544- expect ( Lib . expandObjectPaths ( input ) ) . toEqual ( expected ) ;
548+ expect ( Lib . expandObjectPaths ( input ) ) . toLooseDeepEqual ( expected ) ;
545549 } ) ;
546550
547551 it ( 'expands nested arrays' , function ( ) {
548552 var input = { 'marker[1].range[1]' : 5 } ;
549553 var expected = { marker : [ undefined , { range : [ undefined , 5 ] } ] } ;
550554 var computed = Lib . expandObjectPaths ( input ) ;
551- expect ( computed ) . toEqual ( expected ) ;
555+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
552556 } ) ;
553557
554558 it ( 'expands bracketed array with more nested attributes' , function ( ) {
555559 var input = { 'marker[1]' : { 'color.alpha' : 2 } } ;
556560 var expected = { marker : [ undefined , { color : { alpha : 2 } } ] } ;
557561 var computed = Lib . expandObjectPaths ( input ) ;
558- expect ( computed ) . toEqual ( expected ) ;
562+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
559563 } ) ;
560564
561565 it ( 'expands bracketed array notation without further nesting' , function ( ) {
562566 var input = { 'marker[1]' : 8 } ;
563567 var expected = { marker : [ undefined , 8 ] } ;
564568 var computed = Lib . expandObjectPaths ( input ) ;
565- expect ( computed ) . toEqual ( expected ) ;
569+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
566570 } ) ;
567571
568572 it ( 'expands bracketed array notation with further nesting' , function ( ) {
569573 var input = { 'marker[1].size' : 8 } ;
570574 var expected = { marker : [ undefined , { size : 8 } ] } ;
571575 var computed = Lib . expandObjectPaths ( input ) ;
572- expect ( computed ) . toEqual ( expected ) ;
576+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
573577 } ) ;
574578
575579 it ( 'expands bracketed array notation with further nesting' , function ( ) {
576580 var input = { 'marker[1].size.magnitude' : 8 } ;
577581 var expected = { marker : [ undefined , { size : { magnitude : 8 } } ] } ;
578582 var computed = Lib . expandObjectPaths ( input ) ;
579- expect ( computed ) . toEqual ( expected ) ;
583+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
580584 } ) ;
581585
582586 it ( 'combines changes with single array nesting' , function ( ) {
583587 var input = { 'marker[1].foo' : 5 , 'marker[0].foo' : 4 } ;
584588 var expected = { marker : [ { foo : 4 } , { foo : 5 } ] } ;
585589 var computed = Lib . expandObjectPaths ( input ) ;
586- expect ( computed ) . toEqual ( expected ) ;
590+ expect ( computed ) . toLooseDeepEqual ( expected ) ;
587591 } ) ;
588592
589593 // TODO: This test is unimplemented since it's a currently-unused corner case.
0 commit comments