@@ -450,4 +450,111 @@ describe("RhythmBlocks", () => {
450450 expect ( block . hidden ) . toBe ( true ) ;
451451 } ) ;
452452 } ) ;
453+
454+ describe ( "Edge Cases and Additional Coverage" , ( ) => {
455+ test ( "MultiplyBeatFactorBlock handles fractional factor" , ( ) => {
456+ const block = getBlock ( "multiplybeatfactor" ) ;
457+ block . flow ( [ 0.5 , true ] , logo , 0 , 10 ) ;
458+
459+ expect ( global . Singer . RhythmActions . multiplyNoteValue ) . toHaveBeenCalledWith ( 0.5 , 0 , 10 ) ;
460+ } ) ;
461+
462+ test ( "RhythmicDotBlock handles single dot" , ( ) => {
463+ const block = getBlock ( "rhythmicdot" ) ;
464+ const result = block . flow ( [ true ] , logo , 0 , 10 ) ;
465+
466+ // RhythmicDotBlock has internal implementation, not calling doRhythmicDot
467+ // It should return the expected tuple format
468+ expect ( result ) . toEqual ( [ true , 1 ] ) ;
469+ } ) ;
470+
471+ test ( "RhythmicDot2Block handles multiple dots" , ( ) => {
472+ const block = getBlock ( "rhythmicdot2" ) ;
473+ block . flow ( [ 3 , true ] , logo , 0 , 10 ) ;
474+
475+ expect ( global . Singer . RhythmActions . doRhythmicDot ) . toHaveBeenCalledWith ( 3 , 0 , 10 ) ;
476+ } ) ;
477+
478+ test ( "NewNoteBlock registers correctly" , ( ) => {
479+ const block = getBlock ( "newnote" ) ;
480+ expect ( block ) . toBeDefined ( ) ;
481+ expect ( block . formDefn ) . toBeDefined ( ) ;
482+ } ) ;
483+
484+ test ( "NoteBlock macros are defined" , ( ) => {
485+ const noteBlocks = [
486+ "note1" ,
487+ "note2" ,
488+ "note3" ,
489+ "note4" ,
490+ "note5" ,
491+ "note6" ,
492+ "note7" ,
493+ "note8"
494+ ] ;
495+ noteBlocks . forEach ( blockName => {
496+ const block = getBlock ( blockName ) ;
497+ expect ( block ) . toBeDefined ( ) ;
498+ expect ( block . macro ) . toBeDefined ( ) ;
499+ } ) ;
500+ } ) ;
501+
502+ test ( "OctaveSpaceBlock is defined" , ( ) => {
503+ const block = getBlock ( "octavespace" ) ;
504+ expect ( block ) . toBeDefined ( ) ;
505+ } ) ;
506+
507+ test ( "DefineFrequencyBlock is defined" , ( ) => {
508+ const block = getBlock ( "definefrequency" ) ;
509+ expect ( block ) . toBeDefined ( ) ;
510+ } ) ;
511+
512+ test ( "All rhythm blocks have proper palette assignment" , ( ) => {
513+ const rhythmBlockNames = [
514+ "mynotevalue" ,
515+ "skipfactor" ,
516+ "osctime" ,
517+ "swing" ,
518+ "newswing" ,
519+ "newswing2" ,
520+ "skipnotes" ,
521+ "multiplybeatfactor" ,
522+ "tie" ,
523+ "rhythmicdot" ,
524+ "rhythmicdot2" ,
525+ "rest2" ,
526+ "note" ,
527+ "newnote"
528+ ] ;
529+
530+ rhythmBlockNames . forEach ( blockName => {
531+ const block = activity . registeredBlocks [ blockName ] ;
532+ if ( block ) {
533+ expect ( block . palette ) . toBe ( "rhythm" ) ;
534+ }
535+ } ) ;
536+ } ) ;
537+
538+ test ( "Flow blocks return correct tuple format" , ( ) => {
539+ const flowBlocks = [ "swing" , "newswing2" , "skipnotes" , "multiplybeatfactor" , "tie" ] ;
540+
541+ flowBlocks . forEach ( blockName => {
542+ const block = getBlock ( blockName ) ;
543+ if ( block && block . flow ) {
544+ const result = block . flow ( [ 1 , true ] , logo , 0 , 10 ) ;
545+ if ( result ) {
546+ expect ( Array . isArray ( result ) ) . toBe ( true ) ;
547+ expect ( result . length ) . toBe ( 2 ) ;
548+ }
549+ }
550+ } ) ;
551+ } ) ;
552+
553+ test ( "Rest2Block has correct palette and is beginner block" , ( ) => {
554+ const block = getBlock ( "rest2" ) ;
555+ expect ( block ) . toBeDefined ( ) ;
556+ expect ( block . palette ) . toBe ( "rhythm" ) ;
557+ expect ( block . isBeginner ) . toBe ( true ) ;
558+ } ) ;
559+ } ) ;
453560} ) ;
0 commit comments