-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
117 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,128 @@ | ||
/** | ||
* VexFlow - StaveTie Tests | ||
* Copyright Mohit Muthanna 2010 <mohit@muthanna.com> | ||
*/ | ||
const StaveTieTests = (function () { | ||
function createTest(notesData, setupTies) { | ||
return function (options) { | ||
const f = VexFlowTests.makeFactory(options, 300); | ||
const stave = f.Stave(); | ||
const score = f.EasyScore(); | ||
const voice = score.voice(score.notes.apply(score, notesData)); | ||
const notes = voice.getTickables(); | ||
// [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010. | ||
// MIT License | ||
// | ||
// StaveTie Tests | ||
|
||
setupTies(f, notes, stave); | ||
import { TestOptions, VexFlowTests } from './vexflow_test_helpers'; | ||
import { QUnit, ok } from './declarations'; | ||
import { Stem } from 'stem'; | ||
import { BuilderOptions } from 'easyscore'; | ||
import { Factory } from 'factory'; | ||
import { StaveNote } from 'stavenote'; | ||
import { Stave } from 'stave'; | ||
|
||
f.Formatter().joinVoices([voice]).formatToStave([voice], stave); | ||
const createTest = | ||
(notesData: [string, BuilderOptions], setupTies: (f: Factory, n: StaveNote[], s: Stave) => void) => | ||
(options: TestOptions) => { | ||
const f = VexFlowTests.makeFactory(options, 300); | ||
const stave = f.Stave(); | ||
const score = f.EasyScore(); | ||
const notes = score.notes(notesData[0], notesData[1]); | ||
const voice = score.voice(notes); | ||
// const tickables = voice.getTickables(); // same as the notes that we passed in. | ||
|
||
f.draw(); | ||
setupTies(f, notes, stave); | ||
|
||
ok(true); | ||
}; | ||
} | ||
f.Formatter().joinVoices([voice]).formatToStave([voice], stave); | ||
f.draw(); | ||
ok(true); | ||
}; | ||
|
||
return { | ||
Start: function () { | ||
const run = VexFlowTests.runTests; | ||
const StaveTieTests = { | ||
Start(): void { | ||
QUnit.module('StaveTie'); | ||
const runTests = VexFlowTests.runTests; | ||
|
||
QUnit.module('StaveTie'); | ||
runTests( | ||
'Simple StaveTie', | ||
createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down' }], function (f, notes) { | ||
f.StaveTie({ | ||
from: notes[0], | ||
to: notes[1], | ||
first_indices: [0, 1], | ||
last_indices: [0, 1], | ||
}); | ||
}) | ||
); | ||
|
||
run( | ||
'Simple StaveTie', | ||
createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down' }], function (vf, notes) { | ||
vf.StaveTie({ | ||
from: notes[0], | ||
to: notes[1], | ||
first_indices: [0, 1], | ||
last_indices: [0, 1], | ||
}); | ||
}) | ||
); | ||
runTests( | ||
'Chord StaveTie', | ||
createTest(['(d4 e4 f4)/2, (cn4 f#4 a4)', { stem: 'down' }], function (f, notes) { | ||
f.StaveTie({ | ||
from: notes[0], | ||
to: notes[1], | ||
first_indices: [0, 1, 2], | ||
last_indices: [0, 1, 2], | ||
}); | ||
}) | ||
); | ||
|
||
run( | ||
'Chord StaveTie', | ||
createTest(['(d4 e4 f4)/2, (cn4 f#4 a4)', { stem: 'down' }], function (vf, notes) { | ||
vf.StaveTie({ | ||
from: notes[0], | ||
to: notes[1], | ||
first_indices: [0, 1, 2], | ||
last_indices: [0, 1, 2], | ||
}); | ||
}) | ||
); | ||
runTests( | ||
'Stem Up StaveTie', | ||
createTest(['(d4 e4 f4)/2, (cn4 f#4 a4)', { stem: 'up' }], function (f, notes) { | ||
f.StaveTie({ | ||
from: notes[0], | ||
to: notes[1], | ||
first_indices: [0, 1, 2], | ||
last_indices: [0, 1, 2], | ||
}); | ||
}) | ||
); | ||
|
||
run( | ||
'Stem Up StaveTie', | ||
createTest(['(d4 e4 f4)/2, (cn4 f#4 a4)', { stem: 'up' }], function (vf, notes) { | ||
vf.StaveTie({ | ||
from: notes[0], | ||
to: notes[1], | ||
first_indices: [0, 1, 2], | ||
last_indices: [0, 1, 2], | ||
}); | ||
}) | ||
); | ||
runTests( | ||
'No End Note', | ||
createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down' }], function (f, notes, stave) { | ||
stave.addEndClef('treble'); | ||
f.StaveTie({ | ||
from: notes[1], | ||
to: null, | ||
first_indices: [2], | ||
last_indices: [2], | ||
text: 'slow.', | ||
}); | ||
}) | ||
); | ||
|
||
run( | ||
'No End Note', | ||
createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down' }], function (vf, notes, stave) { | ||
stave.addEndClef('treble'); | ||
vf.StaveTie({ | ||
from: notes[1], | ||
to: null, | ||
first_indices: [2], | ||
last_indices: [2], | ||
text: 'slow.', | ||
}); | ||
}) | ||
); | ||
runTests( | ||
'No Start Note', | ||
createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down' }], function (f, notes, stave) { | ||
stave.addClef('treble'); | ||
f.StaveTie({ | ||
from: null, | ||
to: notes[0], | ||
first_indices: [2], | ||
last_indices: [2], | ||
text: 'H', | ||
}); | ||
}) | ||
); | ||
|
||
run( | ||
'No Start Note', | ||
createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down' }], function (vf, notes, stave) { | ||
stave.addClef('treble'); | ||
vf.StaveTie({ | ||
from: null, | ||
to: notes[0], | ||
first_indices: [2], | ||
last_indices: [2], | ||
text: 'H', | ||
}); | ||
}) | ||
); | ||
runTests( | ||
'Set Direction Down', | ||
createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down' }], function (f, notes) { | ||
f.StaveTie({ | ||
from: notes[0], | ||
to: notes[1], | ||
first_indices: [0, 1], | ||
last_indices: [0, 1], | ||
options: { direction: Stem.DOWN }, | ||
}); | ||
}) | ||
); | ||
|
||
run( | ||
'Set Direction Down', | ||
createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down' }], function (vf, notes) { | ||
vf.StaveTie({ | ||
from: notes[0], | ||
to: notes[1], | ||
first_indices: [0, 1], | ||
last_indices: [0, 1], | ||
options: { | ||
direction: VF.Stem.DOWN, | ||
}, | ||
}); | ||
}) | ||
); | ||
runTests( | ||
'Set Direction Up', | ||
createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down' }], function (f, notes) { | ||
f.StaveTie({ | ||
from: notes[0], | ||
to: notes[1], | ||
first_indices: [0, 1], | ||
last_indices: [0, 1], | ||
options: { direction: Stem.UP }, | ||
}); | ||
}) | ||
); | ||
}, | ||
}; | ||
|
||
run( | ||
'Set Direction Up', | ||
createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down' }], function (vf, notes) { | ||
vf.StaveTie({ | ||
from: notes[0], | ||
to: notes[1], | ||
first_indices: [0, 1], | ||
last_indices: [0, 1], | ||
options: { | ||
direction: VF.Stem.UP, | ||
}, | ||
}); | ||
}) | ||
); | ||
}, | ||
}; | ||
})(); | ||
VexFlowTests.StaveTie = StaveTieTests; | ||
export { StaveTieTests }; |