@@ -108,10 +108,61 @@ const {
108108 base64Encode,
109109 NOTESTEP ,
110110 ACCIDENTALNAMES ,
111- NOTESFLAT
111+ NOTESFLAT ,
112+ NOTENAMES ,
113+ SOLFEGENAMES1 ,
114+ ALLNOTENAMES ,
115+ NOTENAMES1 ,
116+ PITCHES1 ,
117+ PITCHES3
112118} = require ( "../musicutils" ) ;
113119
114120describe ( "musicutils" , ( ) => {
121+ describe ( "musicutils core constants" , ( ) => {
122+ const last = arr => arr [ arr . length - 1 ] ;
123+
124+ it ( "keeps NOTENAMES as the seven natural note letters" , ( ) => {
125+ expect ( NOTENAMES ) . toEqual ( [ "C" , "D" , "E" , "F" , "G" , "A" , "B" ] ) ;
126+ } ) ;
127+
128+ it ( "keeps the expected solfege base syllables in SOLFEGENAMES1 without duplicates" , ( ) => {
129+ const baseSolfegeNames = [
130+ ...new Set ( SOLFEGENAMES1 . map ( name => name . replace ( / [ ♯ ♭ 𝄪 𝄫 ] / gu, "" ) ) )
131+ ] ;
132+
133+ expect ( baseSolfegeNames ) . toEqual ( [ "do" , "re" , "mi" , "fa" , "sol" , "la" , "ti" ] ) ;
134+ expect ( baseSolfegeNames ) . toHaveLength ( 7 ) ;
135+ } ) ;
136+
137+ it ( "preserves the first and last entries for NOTENAMES and SOLFEGENAMES1" , ( ) => {
138+ expect ( NOTENAMES [ 0 ] ) . toBe ( "C" ) ;
139+ expect ( last ( NOTENAMES ) ) . toBe ( "B" ) ;
140+ expect ( SOLFEGENAMES1 [ 0 ] ) . toBe ( "do" ) ;
141+ expect ( last ( SOLFEGENAMES1 ) ) . toBe ( "ti" ) ;
142+ } ) ;
143+
144+ it ( "includes sharps, flats, and double accidentals in ALLNOTENAMES" , ( ) => {
145+ expect ( ALLNOTENAMES ) . toEqual (
146+ expect . arrayContaining ( [ "C#" , "Db" , "Cx" , "Dbb" , "Fx" , "Cb" ] )
147+ ) ;
148+ } ) ;
149+
150+ it ( "keeps note and pitch collections as non-empty arrays of strings" , ( ) => {
151+ [ NOTENAMES , ALLNOTENAMES , NOTENAMES1 , PITCHES1 , PITCHES3 ] . forEach ( collection => {
152+ expect ( Array . isArray ( collection ) ) . toBe ( true ) ;
153+ expect ( collection . length ) . toBeGreaterThan ( 0 ) ;
154+ expect ( collection . every ( item => typeof item === "string" ) ) . toBe ( true ) ;
155+ } ) ;
156+ } ) ;
157+
158+ it ( "keeps major and minor mode definitions at seven steps and one octave" , ( ) => {
159+ expect ( MUSICALMODES . major ) . toHaveLength ( 7 ) ;
160+ expect ( MUSICALMODES . minor ) . toHaveLength ( 7 ) ;
161+ expect ( MUSICALMODES . major . reduce ( ( sum , step ) => sum + step , 0 ) ) . toBe ( 12 ) ;
162+ expect ( MUSICALMODES . minor . reduce ( ( sum , step ) => sum + step , 0 ) ) . toBe ( 12 ) ;
163+ } ) ;
164+ } ) ;
165+
115166 it ( "should set and get Octave Ratio" , ( ) => {
116167 setOctaveRatio ( 4 ) ;
117168 const octaveR = getOctaveRatio ( ) ;
0 commit comments