-
Notifications
You must be signed in to change notification settings - Fork 222
/
Copy pathtest.ts
64 lines (55 loc) · 1.75 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
import DurationValue from "./index";
describe("@tonaljs/duration-value", () => {
test("get shorthand", () => {
expect(DurationValue.get("q")).toEqual({
empty: false,
name: "q",
value: 0.25,
fraction: [1, 4],
dots: "",
shorthand: "q",
names: ["quarter", "crotchet"],
});
expect(DurationValue.get("dl.")).toEqual({
empty: false,
name: "dl.",
dots: ".",
value: 12,
fraction: [12, 1],
names: ["large", "duplex longa", "maxima", "octuple", "octuple whole"],
shorthand: "dl",
});
});
test("get long name", () => {
expect(DurationValue.get("large.")).toMatchObject({
empty: false,
name: "large.",
});
});
test("value", () => {
const DL = [8, 12, 14, 15];
expect(["dl", "dl.", "dl..", "dl..."].map(DurationValue.value)).toEqual(DL);
const L = [4, 6, 7, 7.5];
expect(["l", "l.", "l..", "l..."].map(DurationValue.value)).toEqual(L);
const Q = [0.25, 0.375, 0.4375, 0.46875];
expect(["q", "q.", "q..", "q..."].map(DurationValue.value)).toEqual(Q);
});
test("fraction", () => {
expect(["w", "w.", "w..", "w..."].map(DurationValue.fraction)).toEqual([
[1, 1],
[3, 2],
[7, 4],
[15, 8],
]);
});
test("shorthands", () => {
expect(DurationValue.shorthands().join(",")).toEqual(
"dl,l,d,w,h,q,e,s,t,sf,h,th",
);
});
test("names", () => {
expect(DurationValue.names().join(",")).toEqual(
"large,duplex longa,maxima,octuple,octuple whole,long,longa,double whole,double,breve,whole,semibreve,half,minim,quarter,crotchet,eighth,quaver,sixteenth,semiquaver,thirty-second,demisemiquaver,sixty-fourth,hemidemisemiquaver,hundred twenty-eighth,two hundred fifty-sixth",
);
});
});