-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkey.test.ts
112 lines (98 loc) · 3.27 KB
/
key.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { key, tokenize } from "./index";
describe("@tonaljs/key", () => {
test("props", () => {
expect(key("d mixolydian")).toEqual({
valid: true,
name: "D mixolydian",
tonic: "D",
triad: "D",
seventh: "D7",
alt: 1,
acc: "#",
alteredNotes: ["F#"],
modeName: "mixolydian",
aliases: [],
modeNum: 4,
pcset: 2774,
intervals: ["1P", "2M", "3M", "4P", "5P", "6M", "7m"],
scale: ["D", "E", "F#", "G", "A", "B", "C"]
});
expect(key("none")).toBe(null);
});
test("tokenize", () => {
expect(tokenize("Cb5 lydian")).toEqual(["Cb", "lydian"]);
expect(tokenize("Ax6 Dorian")).toEqual(["A##", "dorian"]);
expect(tokenize("C major")).toEqual(["C", "major"]);
expect(tokenize("dorian")).toEqual(["", "dorian"]);
expect(tokenize("blah")).toEqual(["", "blah"]);
});
/*
test('names', () => {
expect(names(0)).toEqual(['C major'])
expect(names().join('|')).toEqual(
'Ab major|Eb major|Bb major|F major|C major|G major|D major|A major|E major'
)
})
test('degrees', () => {
const major = ['I', 'ii', 'iii', 'IV', 'V', 'vi', 'vii']
expect(degrees('C major')).toEqual(major)
const dorian = ['i', 'ii', 'III', 'IV', 'v', 'vi', 'VII']
expect(degrees('D dorian')).toEqual(dorian)
})
test('alteration', () => {
expect(props('A major').alt).toBe(3)
var Amaj = 'A B C# D E F# G#'.split(' ')
var modes = modeNames(false)
Amaj.forEach(function(tonic, i) {
expect(props(tonic + ' ' + modes[i]).alt).toBe(3)
})
expect(props('Bb major').alt).toBe(-2)
})
test('alteredNotes', () => {
expect(alteredNotes('Eb major')).toEqual(['Bb', 'Eb', 'Ab'])
expect(alteredNotes('A major')).toEqual(['F#', 'C#', 'G#'])
})
test('scale', () => {
expect(scale('G locrian').join(' ')).toEqual('G Ab Bb C Db Eb F')
})
test('leadsheetSymbols', () => {
const symbols = ['M', 'm', 'm', 'M', 'M7', 'm', 'dim']
expect(leadsheetSymbols(symbols, 'C major').join(' ')).toEqual(
'CM Dm Em FM GM7 Am Bdim'
)
})
test('chords', () => {
expect(chords('A major').join(' ')).toEqual(
'AMaj7 Bm7 C#m7 DMaj7 E7 F#m7 G#m7b5'
)
expect(chords('Bb dorian').join(' ')).toEqual(
'Bbm7 Cm7 DbMaj7 Eb7 Fm7 Gm7b5 AbMaj7'
)
})
test('chords with degrees', () => {
expect(chords('A major', ['i', 'ii', 'vii']).join(' ')).toEqual(
'AMaj7 Bm7 G#m7b5'
)
expect(chords('A major', ['V', 'IV', 'I']).join(' ')).toEqual(
'E7 DMaj7 AMaj7'
)
expect(chords('Bb dorian', [5, 4, 1]).join(' ')).toEqual('Fm7 Eb7 Bbm7')
})
test('triads', () => {
expect(triads('A major').join(' ')).toEqual('A Bm C#m D E F#m G#dim')
expect(triads('Bb dorian').join(' ')).toEqual('Bbm Cm Db Eb Fm Gdim Ab')
})
test('secDomChords', () => {
expect(secDomChords('C major').join(' ')).toEqual('G7 A7 B7 C7 D7 E7 F#7')
})
test('modenum', () => {
expect(props('C major').modenum).toEqual(props('C ionian').modenum)
expect(props('C minor').modenum).toEqual(props('C aeolian').modenum)
})
test('relative', () => {
expect(relative('major', 'A minor')).toEqual('C major')
expect(relative('major', 'D minor')).toEqual('F major')
expect(relative('minor', 'D dorian')).toEqual('A minor')
})
*/
});