-
Notifications
You must be signed in to change notification settings - Fork 220
/
test.ts
73 lines (69 loc) · 1.64 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
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
import AbcNotation from "./index";
describe("@tonaljs/abc-notation", () => {
test("tokenize", () => {
expect(AbcNotation.tokenize("C,',")).toEqual(["", "C", ",',"]);
expect(AbcNotation.tokenize("g,,'")).toEqual(["", "g", ",,'"]);
expect(AbcNotation.tokenize("")).toEqual(["", "", ""]);
expect(AbcNotation.tokenize("m")).toEqual(["", "", ""]);
expect(AbcNotation.tokenize("c#")).toEqual(["", "", ""]);
});
test("transpose", () => {
expect(AbcNotation.transpose("=C", "P19")).toEqual("g'");
});
test("distance", () => {
expect(AbcNotation.distance("=C", "g")).toEqual("12P");
});
test("toNote", () => {
const ABC = [
"__A,,",
"_B,",
"=C",
"d",
"^e'",
"^^f''",
"G,,''",
"g,,,'''",
"",
];
const SCIENTIFIC = [
"Abb2",
"Bb3",
"C4",
"D5",
"E#6",
"F##7",
"G4",
"G5",
"",
];
expect(ABC.map(AbcNotation.abcToScientificNotation)).toEqual(SCIENTIFIC);
});
test("toAbc", () => {
const SCIENTIFIC = [
"Abb2",
"Bb3",
"C4",
"D5",
"E#6",
"F##7",
"G#2",
"Gb7",
"",
];
const ABC = ["__A,,", "_B,", "C", "d", "^e'", "^^f''", "^G,,", "_g''", ""];
expect(SCIENTIFIC.map(AbcNotation.scientificToAbcNotation)).toEqual(ABC);
});
test("toAbc Octave 0", () => {
const SCIENTIFIC = ["A0", "Bb0", "C0", "D0", "E#0", "F##0", "G#0"];
const ABC = [
"A,,,,",
"_B,,,,",
"C,,,,",
"D,,,,",
"^E,,,,",
"^^F,,,,",
"^G,,,,",
];
expect(SCIENTIFIC.map(AbcNotation.scientificToAbcNotation)).toEqual(ABC);
});
});