@@ -40,21 +40,25 @@ describe('setupVolumeActions', () => {
4040 ithTurtle : jest . fn ( ) ,
4141 } ,
4242 blocks : {
43- blockList : { 1 : { } } ,
43+ blockList : {
44+ 1 : { connections : [ { } , { } ] } ,
45+ } ,
4446 } ,
4547 logo : {
4648 setDispatchBlock : jest . fn ( ) ,
4749 setTurtleListener : jest . fn ( ) ,
4850 synth : {
4951 loadSynth : jest . fn ( ) ,
52+ setMasterVolume : jest . fn ( ) ,
5053 } ,
5154 notation : {
5255 notationBeginArticulation : jest . fn ( ) ,
5356 notationEndArticulation : jest . fn ( ) ,
5457 notationEndCrescendo : jest . fn ( ) ,
5558 } ,
5659 blockList : {
57- block1 : { connections : [ { } , { } ] } ,
60+ 1 : { connections : [ { } , { } ] } ,
61+ 2 : { connections : [ { } ] } ,
5862 } ,
5963 } ,
6064 errorMsg : jest . fn ( ) ,
@@ -67,7 +71,7 @@ describe('setupVolumeActions', () => {
6771 activity . logo . blockList [ 'testBlock' ] = { connections : [ { } ] } ;
6872 targetTurtle = {
6973 singer : {
70- synthVolume : { default : [ DEFAULTVOLUME ] } ,
74+ synthVolume : { default : [ DEFAULTVOLUME ] } ,
7175 crescendoInitialVolume : { default : [ DEFAULTVOLUME ] } ,
7276 crescendoDelta : [ ] ,
7377 inCrescendo : [ ] ,
@@ -78,10 +82,10 @@ describe('setupVolumeActions', () => {
7882 } ,
7983 } ;
8084 activity . turtles . ithTurtle . mockReturnValue ( targetTurtle ) ;
81-
85+
8286 setupVolumeActions ( activity ) ;
8387 activity . errorMsg . mockImplementation ( ( message ) => {
84- if ( message . includes ( 'not found' ) && ! message . includes ( 'invalidSynth' ) ) {
88+ if ( message . includes ( 'not found' ) ) {
8589 message = message . replace ( "null" , "invalidSynth" ) ;
8690 }
8791 return message ;
@@ -218,14 +222,18 @@ describe('setupVolumeActions', () => {
218222 } ) ;
219223
220224 it ( 'should set synth volume correctly' , ( ) => {
221- Singer . VolumeActions . setSynthVolume ( 'piano' , 80 , 0 , 'block1' ) ;
222- expect ( targetTurtle . singer . synthVolume [ 'piano' ] ) . toContain ( 80 ) ;
223- expect ( Singer . setSynthVolume ) . toHaveBeenCalledWith ( activity . logo , 0 , 'piano' , 80 ) ;
225+ targetTurtle . singer . synthVolume [ 'default' ] = [ DEFAULTVOLUME ] ;
226+ activity . logo . blockList = { testBlock : { connections : [ { } ] } } ;
227+ const someBlockId = 'testBlock' ;
228+ Singer . VolumeActions . setSynthVolume ( 'default' , 70 , 0 , someBlockId ) ;
229+ expect ( targetTurtle . singer . synthVolume [ 'default' ] ) . toContain ( 70 ) ;
230+ expect ( Singer . setSynthVolume ) . toHaveBeenCalledWith ( activity . logo , 0 , 'default' , 70 ) ;
224231 } ) ;
225232
226233 it ( 'should not set volume for undefined synth' , ( ) => {
227234 const errorMsgSpy = jest . spyOn ( activity , 'errorMsg' ) ;
228- Singer . VolumeActions . setSynthVolume ( 'null' , 50 , 0 , 'block1' ) ;
235+ activity . logo . blockList [ 'testBlock' ] = { connections : [ { } ] } ;
236+ Singer . VolumeActions . setSynthVolume ( 'null' , 50 , 0 , 'testBlock' ) ;
229237 expect ( errorMsgSpy ) . toHaveBeenCalledWith ( 'nullnot found' ) ;
230- } ) ;
238+ } ) ;
231239} ) ;
0 commit comments