forked from 0xfe/vexflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmocks.ts
104 lines (85 loc) · 1.89 KB
/
mocks.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
// [VexFlow](https://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
// MIT License
//
// TickContext Mocks
import { Fraction } from '../src/fraction';
import { NoteMetrics } from '../src/note';
import { Stave } from '../src/stave';
import { Tickable } from '../src/tickable';
import { TickContext } from '../src/tickcontext';
import { Voice } from '../src/voice';
class MockTickable extends Tickable {
tickContext?: TickContext;
ticks: Fraction = new Fraction(1, 1);
voice?: Voice;
stave?: Stave;
width: number = 0;
ignore_ticks: boolean = false;
init(): void {
// DO NOTHING.
}
getX(): number {
// eslint-disable-next-line
return this.tickContext!.getX();
}
getIntrinsicTicks(): number {
return this.ticks.value();
}
getTicks(): Fraction {
return this.ticks;
}
setTicks(t: number): this {
this.ticks = new Fraction(t, 1);
return this;
}
// Called by TickContext.preFormat().
getMetrics(): NoteMetrics {
return {
width: 0,
glyphWidth: 0,
notePx: this.width,
modLeftPx: 0,
modRightPx: 0,
leftDisplacedHeadPx: 0,
rightDisplacedHeadPx: 0,
glyphPx: 0,
};
}
getWidth(): number {
return this.width;
}
setWidth(w: number): this {
this.width = w;
return this;
}
setVoice(v: Voice): this {
this.voice = v;
return this;
}
setStave(stave: Stave): this {
this.stave = stave;
return this;
}
getStave(): Stave | undefined {
return this.stave;
}
setTickContext(tc: TickContext): this {
this.tickContext = tc;
return this;
}
setIgnoreTicks(flag: boolean): this {
this.ignore_ticks = flag;
return this;
}
shouldIgnoreTicks(): boolean {
return this.ignore_ticks;
}
preFormat(): void {
// DO NOTHING.
}
// eslint-disable-next-line
draw(...args: any[]): void {
// DO NOTHING.
}
}
export { MockTickable };