forked from tonaljs/tonal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
30 lines (26 loc) · 1.13 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
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);
});
});