Skip to content

Commit

Permalink
Merge pull request #32 from simonppg/testScales
Browse files Browse the repository at this point in the history
Tests scales modes
  • Loading branch information
simonppg authored Sep 23, 2023
2 parents 13923f3 + 64455c5 commit bc83780
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
16 changes: 16 additions & 0 deletions __tests__/ScaleFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@ const formatter = new ScaleFormatter()
test('Convert to ScalesCodes', () => {
expect(formatter.toScaleCode(IntervalPattern.mayor)).toBe(ScalesCode.mayor)
expect(formatter.toScaleCode(IntervalPattern.pentatonic)).toBe(ScalesCode.mayorPentatonic)

expect(formatter.toScaleCode(IntervalPattern.ionian)).toBe(ScalesCode.ionian)
expect(formatter.toScaleCode(IntervalPattern.aeolian)).toBe(ScalesCode.aeolian)
expect(formatter.toScaleCode(IntervalPattern.dorian)).toBe(ScalesCode.dorian)
expect(formatter.toScaleCode(IntervalPattern.phrygian)).toBe(ScalesCode.phrygian)
expect(formatter.toScaleCode(IntervalPattern.lydian)).toBe(ScalesCode.lydian)
expect(formatter.toScaleCode(IntervalPattern.mixolydian)).toBe(ScalesCode.mixolydian)
expect(formatter.toScaleCode(IntervalPattern.locrian)).toBe(ScalesCode.locrian)
})

test('Convert to IntervalPattern', () => {
expect(formatter.toIntervalPattern(ScalesCode.mayor)).toStrictEqual(IntervalPattern.mayor)
expect(formatter.toIntervalPattern(ScalesCode.mayorPentatonic)).toStrictEqual(IntervalPattern.pentatonic)

expect(formatter.toIntervalPattern(ScalesCode.ionian)).toStrictEqual(IntervalPattern.ionian)
expect(formatter.toIntervalPattern(ScalesCode.aeolian)).toStrictEqual(IntervalPattern.aeolian)
expect(formatter.toIntervalPattern(ScalesCode.dorian)).toStrictEqual(IntervalPattern.dorian)
expect(formatter.toIntervalPattern(ScalesCode.phrygian)).toStrictEqual(IntervalPattern.phrygian)
expect(formatter.toIntervalPattern(ScalesCode.lydian)).toStrictEqual(IntervalPattern.lydian)
expect(formatter.toIntervalPattern(ScalesCode.mixolydian)).toStrictEqual(IntervalPattern.mixolydian)
expect(formatter.toIntervalPattern(ScalesCode.locrian)).toStrictEqual(IntervalPattern.locrian)
})

10 changes: 9 additions & 1 deletion src/IntervalPattern.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
export const IntervalPattern = {
mayor: [2, 2, 1, 2, 2, 2, 1],
blues: [3, 2, 1, 1, 3, 2],
pentatonic: [2, 2, 3, 2, 3]
pentatonic: [2, 2, 3, 2, 3],

ionian: [2, 2, 1, 2, 2, 2, 1],
dorian: [2, 1, 2, 2, 2, 1, 2],
phrygian: [1, 2, 2, 2, 1, 2, 2],
lydian: [2, 2, 2, 1, 2, 2, 1],
mixolydian: [2, 2, 1, 2, 2, 1, 2],
aeolian: [2, 1, 2, 2, 1, 2, 2],
locrian: [1, 2, 2, 1, 2, 2, 2]
} as const
10 changes: 9 additions & 1 deletion src/ScalesCode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
export const ScalesCode = {
mayor: 2741,
mayorPentatonic: 661
mayorPentatonic: 661,

ionian: 2741,
aeolian: 1453,
dorian: 1709,
phrygian: 1451,
lydian: 2773,
mixolydian: 1717,
locrian: 1387
} as const

0 comments on commit bc83780

Please sign in to comment.