@@ -81,6 +81,17 @@ describe('state handler', () => {
8181 my_callback . should . be . calledWith ( state_handler , my_callback )
8282 } )
8383
84+ it ( `callback should not be called when no actual change happens - ${ method } ` , ( ) => {
85+ const my_callback = sinon . spy ( )
86+ const injector = require ( 'inject-loader!./state_handler.js' )
87+ const state_handler = injector ( {
88+ 'lodash' : { 'isEqual' : ( ) => true }
89+ } ) . default ( )
90+ state_handler . subscribe ( my_callback )
91+ state_handler [ method ] ( 'foo' , 42 )
92+ my_callback . should . not . be . called ( )
93+ } )
94+
8495 it ( `callback should retrieve collect state - ${ method } ` , ( ) => {
8596 let retrieved_state = null
8697 const my_callback = ( handler ) => {
@@ -112,7 +123,10 @@ describe('state handler', () => {
112123
113124 it ( 'callback should be called again with re-subscribe' , ( ) => {
114125 const my_callback = sinon . spy ( function ( ) { state_handler . subscribe ( my_callback ) } )
115- const state_handler = create_state_handler ( )
126+ const injector = require ( 'inject-loader!./state_handler.js' )
127+ const state_handler = injector ( {
128+ 'lodash' : { 'isEqual' : ( ) => false }
129+ } ) . default ( )
116130 state_handler . subscribe ( my_callback )
117131 state_handler . set_variable ( 'foo' , 42 )
118132 state_handler . set_variable ( 'foo' , 42 )
0 commit comments