@@ -4,20 +4,14 @@ import { TUNINGS } from '../../constants/tunings';
44import AbcObjects from '../../test-data/abcjs-objects' ;
55import AbcKeySignatures from '../../test-data/abc-key-signatures' ;
66
7- const tuning = {
8- displayName : 'Guitar (EADGBE)' ,
9- strings : [ 'e/3' , 'a/3' , 'd/4' , 'g/4' , 'b/4' , 'e/5' ] ,
10- type : 'strings_fretted'
11- } ;
12-
137// TODO: separate unit tests from integration
148
159test ( 'e3 is lowest note on guitar' , ( ) => {
1610 const keys = [ 'e/3' ] ;
1711 const abcKeySignature = AbcKeySignatures . CMajor ;
1812 const barContents = [ AbcObjects . Notes . Eighths . F ] ;
1913
20- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , false ) ) . toStrictEqual ( [ { str : 6 , fret : 0 } ] ) ;
14+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 6 , fret : 0 } ] ) ;
2115} ) ;
2216
2317test ( 'sharped note causes itself and later notes to be sharped' , ( ) => {
@@ -28,9 +22,9 @@ test('sharped note causes itself and later notes to be sharped', () => {
2822 const barContents = [ f , fSharp , f ] ;
2923
3024 // str: 1, fret: 1 is F natural
31- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 1 } ] ) ;
32- expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
33- expect ( getTabPosition ( keys , abcKeySignature , barContents , 2 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
25+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 1 } ] ) ;
26+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
27+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 2 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
3428} ) ;
3529
3630test ( 'sharp in key signature causes note to be sharped' , ( ) => {
@@ -40,7 +34,7 @@ test('sharp in key signature causes note to be sharped', () => {
4034 const barContents = [ f ] ;
4135
4236 // str: 1, fret: 2 is F sharp
43- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
37+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
4438} ) ;
4539
4640// bugfix: in abcjs key sig, accidental.note when the note is 'b',
@@ -52,9 +46,9 @@ test('in B Flat Minor key, B notes get flatted', () => {
5246 const barContents = [ b ] ;
5347
5448 // str: 1, fret: 6 is B flat
55- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 6 } ] ) ;
49+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 6 } ] ) ;
5650 // now with C major key sig, should be a B natural
57- expect ( getTabPosition ( keys , AbcKeySignatures . CMajor , barContents , 0 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 7 } ] ) ;
51+ expect ( getTabPosition ( keys , AbcKeySignatures . CMajor , barContents , 0 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 7 } ] ) ;
5852} ) ;
5953
6054test ( 'sharped note, when sharp already exists in key sig, doesnt sharp the note twice' , ( ) => {
@@ -65,7 +59,7 @@ test('sharped note, when sharp already exists in key sig, doesnt sharp the note
6559
6660 // str: 1, fret: 1 is F natural and str: 1, fret: 2 is F sharp. we're checking to make
6761 // sure it doesn't somehow end up str: 1, fret: 3
68- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
62+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
6963} ) ;
7064
7165test ( 'natural accidental cancels out key sig sharp' , ( ) => {
@@ -76,7 +70,7 @@ test('natural accidental cancels out key sig sharp', () => {
7670
7771 // the natural accidental on the specific note should cancel out the sharp accidental in the key sig
7872 // str: 1, fret: 1 is F natural
79- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 1 } ] ) ;
73+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 1 } ] ) ;
8074} ) ;
8175
8276test ( 'grace note - sharped grace note causes itself and later grace notes to be sharped' , ( ) => {
@@ -88,9 +82,9 @@ test('grace note - sharped grace note causes itself and later grace notes to be
8882
8983 // str: 1, fret: 1 is F natural
9084 // passing is GraceNote true, meaning we're getting tab position for the grace notes here
91- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , true ) ) . toStrictEqual ( [ { str : 1 , fret : 1 } ] ) ;
92- expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , tuning , true ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
93- expect ( getTabPosition ( keys , abcKeySignature , barContents , 2 , tuning , true ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
85+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , true ) ) . toStrictEqual ( [ { str : 1 , fret : 1 } ] ) ;
86+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , TUNINGS . GUITAR_STANDARD , true ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
87+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 2 , TUNINGS . GUITAR_STANDARD , true ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
9488} ) ;
9589
9690test ( 'grace note - sharp in key signature causes grace note to be sharped' , ( ) => {
@@ -100,7 +94,7 @@ test('grace note - sharp in key signature causes grace note to be sharped', () =
10094 const barContents = [ cWithFGraceNote ] ;
10195
10296 // str: 1, fret: 2 is F sharp
103- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , true ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
97+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , true ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
10498} ) ;
10599
106100test ( 'grace note - sharped grace note causes later regular notes to be sharped' , ( ) => {
@@ -112,7 +106,7 @@ test('grace note - sharped grace note causes later regular notes to be sharped',
112106
113107 // passing isGraceNote as false because we're testing a regular F note at position 1 and
114108 // confirming the sharp from previously sharped F grace note applies to it
115- expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
109+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
116110} ) ;
117111
118112test ( 'grace note - sharped regular note causes later grace notes to be sharped' , ( ) => {
@@ -124,7 +118,7 @@ test('grace note - sharped regular note causes later grace notes to be sharped',
124118
125119 // passingisGraceNote as true because we're testing the F grace note attached to the C note
126120 // in position 1 and confirming it's sharped by the accidental from the F Sharp at position 0
127- expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , tuning , true ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
121+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , TUNINGS . GUITAR_STANDARD , true ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
128122} ) ;
129123
130124
@@ -136,7 +130,7 @@ test('grace note - natural accidental on grace note cancels out key sig sharp',
136130
137131 // the natural accidental on the specific grace note should cancel out the sharp accidental in the key sig
138132 // should be str: 1, fret: 1 for F natural
139- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , true ) ) . toStrictEqual ( [ { str : 1 , fret : 1 } ] ) ;
133+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , true ) ) . toStrictEqual ( [ { str : 1 , fret : 1 } ] ) ;
140134} ) ;
141135
142136
@@ -148,7 +142,7 @@ test('grace note - accidental on grace note does affect attached regular note',
148142
149143 // The regular F has a F Sharp grace note attached (before) it, so the note should
150144 // become sharped, testing the regular note F so isGraceNote is false
151- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
145+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
152146} ) ;
153147
154148test ( 'grace note - grace is not affected by accidental on attached regular note' , ( ) => {
@@ -159,7 +153,7 @@ test('grace note - grace is not affected by accidental on attached regular note'
159153
160154 // Now it's a F Sharp regular note with a F grace note attached having no accidental. The
161155 // regular note comes "after" the grace not, so the grace note pitch should be F Natural
162- expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , tuning , true ) ) . toStrictEqual ( [ { str : 1 , fret : 1 } ] ) ;
156+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 0 , TUNINGS . GUITAR_STANDARD , true ) ) . toStrictEqual ( [ { str : 1 , fret : 1 } ] ) ;
163157} ) ;
164158
165159test ( 'grace note - accidental on n-1 regular note will apply to regular note n over accidental on n-1 grace note' , ( ) => {
@@ -170,7 +164,7 @@ test('grace note - accidental on n-1 regular note will apply to regular note n o
170164 const barContents = [ fSharpWithFFlatGraceNote , f ] ;
171165
172166 // The sharp accidental from the n-1 note should be applied, not the flat from the n-1 grace note
173- expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , tuning , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
167+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , TUNINGS . GUITAR_STANDARD , false ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
174168} ) ;
175169
176170test ( 'grace note - accidental on n-1 regular note will apply to grace note n over accidental on n-1 grace note' , ( ) => {
@@ -181,7 +175,7 @@ test('grace note - accidental on n-1 regular note will apply to grace note n ove
181175 const barContents = [ fSharpWithFFlatGraceNote , f ] ;
182176
183177 // The sharp accidental from the n-1 note should be applied, not the flat from the n-1 grace note
184- expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , tuning , true ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
178+ expect ( getTabPosition ( keys , abcKeySignature , barContents , 1 , TUNINGS . GUITAR_STANDARD , true ) ) . toStrictEqual ( [ { str : 1 , fret : 2 } ] ) ;
185179} ) ;
186180
187181// TEST FOR TIN WHISTLE
0 commit comments