-
Notifications
You must be signed in to change notification settings - Fork 223
/
Copy pathtest.ts
35 lines (31 loc) · 1.1 KB
/
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
import { detect } from "./index";
describe("@tonal/chord-detect", () => {
test("detect", () => {
expect(detect(["D", "F#", "A", "C"])).toEqual(["D7"]);
expect(detect(["F#", "A", "C", "D"])).toEqual(["D7/F#"]);
expect(detect(["A", "C", "D", "F#"])).toEqual(["D7/A"]);
expect(detect(["E", "G#", "B", "C#"])).toEqual(["E6", "C#m7/E"]);
});
test("assume perfect 5th", () => {
expect(detect(["D", "F", "C"], { assumePerfectFifth: true })).toEqual([
"Dm7",
]);
expect(detect(["D", "F", "C"], { assumePerfectFifth: false })).toEqual([]);
expect(detect(["D", "F", "A", "C"], { assumePerfectFifth: true })).toEqual([
"Dm7",
"F6/D",
]);
expect(detect(["D", "F", "A", "C"], { assumePerfectFifth: false })).toEqual(
["Dm7", "F6/D"],
);
expect(detect(["D", "F", "Ab", "C"], { assumePerfectFifth: true })).toEqual(
["Dm7b5", "Fm6/D"],
);
});
test("(regression) detect aug", () => {
expect(detect(["C", "E", "G#"])).toEqual(["Caug", "Eaug/C", "G#aug/C"]);
});
test("edge cases", () => {
expect(detect([])).toEqual([]);
});
});