@@ -55,67 +55,6 @@ describe('finance charts defaults:', function() {
5555 expect ( out . _fullData . length ) . toEqual ( 2 ) ;
5656 } ) ;
5757
58- it ( 'should not mutate user data' , function ( ) {
59- var trace0 = Lib . extendDeep ( { } , mock0 , {
60- type : 'ohlc'
61- } ) ;
62-
63- var trace1 = Lib . extendDeep ( { } , mock1 , {
64- type : 'candlestick'
65- } ) ;
66-
67- var out = _supply ( [ trace0 , trace1 ] ) ;
68- expect ( out . data [ 0 ] ) . toBe ( trace0 ) ;
69- expect ( out . data [ 0 ] . transforms ) . toBeUndefined ( ) ;
70- expect ( out . data [ 1 ] ) . toBe ( trace1 ) ;
71- expect ( out . data [ 1 ] . transforms ) . toBeUndefined ( ) ;
72-
73- // ... and in an idempotent way
74-
75- var out2 = _supply ( out . data ) ;
76- expect ( out2 . data [ 0 ] ) . toBe ( trace0 ) ;
77- expect ( out2 . data [ 0 ] . transforms ) . toBeUndefined ( ) ;
78- expect ( out2 . data [ 1 ] ) . toBe ( trace1 ) ;
79- expect ( out2 . data [ 1 ] . transforms ) . toBeUndefined ( ) ;
80- } ) ;
81-
82- it ( 'should work with transforms' , function ( ) {
83- var trace0 = Lib . extendDeep ( { } , mock1 , {
84- type : 'ohlc' ,
85- transforms : [ {
86- type : 'filter'
87- } ]
88- } ) ;
89-
90- var trace1 = Lib . extendDeep ( { } , mock0 , {
91- type : 'candlestick' ,
92- transforms : [ {
93- type : 'filter'
94- } ]
95- } ) ;
96-
97- var out = _supply ( [ trace0 , trace1 ] ) ;
98-
99- expect ( out . data . length ) . toEqual ( 2 ) ;
100- expect ( out . _fullData . length ) . toEqual ( 2 ) ;
101-
102- var transformTypesIn = out . data . map ( function ( trace ) {
103- return trace . transforms . map ( function ( opts ) {
104- return opts . type ;
105- } ) ;
106- } ) ;
107-
108- expect ( transformTypesIn ) . toEqual ( [ [ 'filter' ] , [ 'filter' ] ] ) ;
109-
110- var transformTypesOut = out . _fullData . map ( function ( fullTrace ) {
111- return fullTrace . transforms . map ( function ( opts ) {
112- return opts . type ;
113- } ) ;
114- } ) ;
115-
116- expect ( transformTypesOut ) . toEqual ( [ [ 'filter' ] , [ 'filter' ] ] ) ;
117- } ) ;
118-
11958 it ( 'should not slice data arrays but record minimum supplied length' , function ( ) {
12059 function assertDataLength ( trace , fullTrace , len ) {
12160 expect ( fullTrace . visible ) . toBe ( true ) ;
@@ -446,110 +385,6 @@ describe('finance charts calc', function() {
446385 expect ( mapGet ( out [ 1 ] , 'empty' ) ) . toEqual ( empties ) ;
447386 } ) ;
448387
449- it ( 'should work with *filter* transforms' , function ( ) {
450- var trace0 = Lib . extendDeep ( { } , mock1 , {
451- type : 'ohlc' ,
452- tickwidth : 0.05 ,
453- transforms : [ {
454- type : 'filter' ,
455- operation : '>' ,
456- target : 'open' ,
457- value : 33
458- } ]
459- } ) ;
460-
461- var trace1 = Lib . extendDeep ( { } , mock1 , {
462- type : 'candlestick' ,
463- transforms : [ {
464- type : 'filter' ,
465- operation : '{}' ,
466- target : 'x' ,
467- value : [ '2016-09-01' , '2016-09-10' ]
468- } ]
469- } ) ;
470-
471- var out = _calc ( [ trace0 , trace1 ] ) ;
472-
473- expect ( out . length ) . toEqual ( 2 ) ;
474-
475- expect ( out [ 0 ] . x ) . toEqual ( [
476- '2016-09-01' , '2016-09-02' , '2016-09-03' , '2016-09-05' , '2016-09-06' , '2016-09-07' , '2016-09-10'
477- ] ) ;
478- expect ( out [ 0 ] . open ) . toEqual ( [
479- 33.01 , 33.31 , 33.50 , 34.12 , 33.05 , 33.31 , 33.50
480- ] ) ;
481-
482- expect ( out [ 1 ] . x ) . toEqual ( [
483- '2016-09-01' , '2016-09-10'
484- ] ) ;
485- expect ( out [ 1 ] . close ) . toEqual ( [
486- 34.10 , 33.70
487- ] ) ;
488- } ) ;
489-
490- it ( 'should work with *groupby* transforms (ohlc)' , function ( ) {
491- var opts = {
492- type : 'groupby' ,
493- groups : [ 'b' , 'b' , 'b' , 'a' ] ,
494- } ;
495-
496- var trace0 = Lib . extendDeep ( { } , mock1 , {
497- type : 'ohlc' ,
498- tickwidth : 0.05 ,
499- transforms : [ opts ]
500- } ) ;
501-
502- var out = _calc ( [ trace0 ] ) ;
503-
504- expect ( out . length ) . toBe ( 2 ) ;
505-
506- expect ( out [ 0 ] . name ) . toBe ( 'b' ) ;
507- expect ( out [ 0 ] . x ) . toEqual ( [
508- '2016-09-01' , '2016-09-02' , '2016-09-03'
509- ] ) ;
510- expect ( out [ 0 ] . open ) . toEqual ( [
511- 33.01 , 33.31 , 33.5
512- ] ) ;
513-
514- expect ( out [ 1 ] . name ) . toBe ( 'a' ) ;
515- expect ( out [ 1 ] . x ) . toEqual ( [
516- '2016-09-04'
517- ] ) ;
518- expect ( out [ 1 ] . open ) . toEqual ( [
519- 32.06
520- ] ) ;
521- } ) ;
522-
523- it ( 'should work with *groupby* transforms (candlestick)' , function ( ) {
524- var opts = {
525- type : 'groupby' ,
526- groups : [ 'a' , 'b' , 'b' , 'a' ] ,
527- } ;
528-
529- var trace0 = Lib . extendDeep ( { } , mock1 , {
530- type : 'candlestick' ,
531- transforms : [ opts ]
532- } ) ;
533-
534- var out = _calc ( [ trace0 ] ) ;
535-
536- expect ( out [ 0 ] . name ) . toEqual ( 'a' ) ;
537- expect ( out [ 0 ] . x ) . toEqual ( [
538- '2016-09-01' , '2016-09-04'
539- ] ) ;
540- expect ( out [ 0 ] . open ) . toEqual ( [
541- 33.01 , 32.06
542- ] ) ;
543-
544- expect ( out [ 1 ] . name ) . toEqual ( 'b' ) ;
545- expect ( out [ 1 ] . x ) . toEqual ( [
546- '2016-09-02' , '2016-09-03'
547- ] ) ;
548- expect ( out [ 1 ] . open ) . toEqual ( [
549- 33.31 , 33.5
550- ] ) ;
551- } ) ;
552-
553388 it ( 'should use the smallest trace minimum x difference to convert *tickwidth* to data coords for all traces attached to a given x-axis' , function ( ) {
554389 var trace0 = Lib . extendDeep ( { } , mock1 , {
555390 type : 'ohlc'
0 commit comments