-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update tests and surface fretting type functionality to site
- Loading branch information
1 parent
8d4bcd1
commit 9540330
Showing
4 changed files
with
81 additions
and
7 deletions.
There are no files selected for viewing
54 changes: 52 additions & 2 deletions
54
packages/react-guitar-fretter/src/__test__/fretter.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,65 @@ | ||
import fretter from '../' | ||
import fretter, { toSemitones } from '../' | ||
|
||
const toSemitones = (text: string) => text.split('').map((c) => c === '1') | ||
describe('toSemitones()', () => { | ||
it(`maps correctly`, () => | ||
// prettier-ignore | ||
expect( | ||
toSemitones('01010101010') | ||
).toEqual([false, true, false, true, false, true, false, true, false, true, false])) | ||
}) | ||
|
||
describe('fretter()', () => { | ||
it(`frets C major`, () => | ||
expect( | ||
fretter({ root: 0, semitones: toSemitones('00010010000') })[0] | ||
).toEqual([0, 1, 0, 2, 3, -1])) | ||
|
||
it(`frets C major barre`, () => | ||
expect( | ||
fretter( | ||
{ | ||
root: 0, | ||
semitones: toSemitones('00010010000'), | ||
}, | ||
{ frettingType: 'barre' } | ||
)[0] | ||
).toEqual([3, 5, 5, 5, 3, -1])) | ||
|
||
it(`frets C major open`, () => | ||
expect( | ||
fretter( | ||
{ | ||
root: 0, | ||
semitones: toSemitones('00010010000'), | ||
}, | ||
{ frettingType: 'open' } | ||
)[0] | ||
).toEqual([0, 1, 0, 2, 3, -1])) | ||
|
||
it(`frets A minor`, () => | ||
expect( | ||
fretter({ root: 9, semitones: toSemitones('00100010000') })[0] | ||
).toEqual([0, 1, 2, 2, 0, -1])) | ||
|
||
it(`frets A minor barre`, () => | ||
expect( | ||
fretter( | ||
{ | ||
root: 9, | ||
semitones: toSemitones('00100010000'), | ||
}, | ||
{ frettingType: 'barre' } | ||
)[0] | ||
).toEqual([5, 5, 5, 7, 7, 5])) | ||
|
||
it(`frets A minor open`, () => | ||
expect( | ||
fretter( | ||
{ | ||
root: 9, | ||
semitones: toSemitones('00100010000'), | ||
}, | ||
{ frettingType: 'open' } | ||
)[0] | ||
).toEqual([0, 1, 2, 2, 0, -1])) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters