@@ -338,7 +338,7 @@ describe('Component', function() {
338338 '22' : [ 'foo' ] ,
339339 'state_handler' : state_handler
340340 } ,
341- 'format_value_return2' : {
341+ 'format_value_return2' : {
342342 '22' : [ 'foo' ] ,
343343 'state_handler' : state_handler
344344 }
@@ -552,4 +552,37 @@ describe('Component', function() {
552552 my_init . should . be . calledOnce ( )
553553 } )
554554
555+ it ( 'calls format_value with proper data' , ( ) => {
556+ const state_handler = {
557+ 'subscribe' : sinon . spy ( ) ,
558+ 'get_state' : sinon . stub ( ) . returns ( { 'x' : '2' } ) }
559+ const format_value_return = {
560+ 'state_handler' : state_handler
561+ }
562+ const my_data = 'this is data that has to be formatted'
563+ const { format_value } = call_test_component_with ( {
564+ 'instance_args' : format_value_return ,
565+ 'format_value_return' : format_value_return ,
566+ 'format_value_return2' : format_value_return ,
567+ 'data' : my_data
568+ } )
569+ format_value . should . be . calledWith ( my_data )
570+ } )
571+
572+ it ( 'calls render with formatted data' , ( ) => {
573+ const state_handler = {
574+ 'subscribe' : sinon . spy ( ) ,
575+ 'get_state' : sinon . stub ( ) . returns ( { 'x' : '2' , 'y' : 'foo' } ) }
576+ const format_value_return = {
577+ 'state_handler' : state_handler
578+ }
579+ const { my_render } = call_test_component_with ( {
580+ 'instance_args' : format_value_return ,
581+ 'format_value_return' : format_value_return ,
582+ 'format_value_return2' : format_value_return ,
583+ 'data' : 'this is not formatted'
584+ } )
585+ my_render . should . be . calledWith ( sinon . match . any , sinon . match . any , format_value_return )
586+ } )
587+
555588} )
0 commit comments