|
| 1 | +// [VexFlow](https://vexflow.com) - Copyright (c) Mohit Muthanna 2010. |
| 2 | +// MIT License |
| 3 | +// |
| 4 | +// Unison Tests |
| 5 | +import { TestOptions, VexFlowTests } from './vexflow_test_helpers'; |
| 6 | + |
| 7 | +import { Tables } from '../src/tables'; |
| 8 | + |
| 9 | +const UnisonTests = { |
| 10 | + Start(): void { |
| 11 | + QUnit.module('Unison'); |
| 12 | + const run = VexFlowTests.runTests; |
| 13 | + run('Simple(true)', simple, { unison: true, voice1: 'e4/q, e4/q, e4/h', voice2: 'e4/8, e4/8, e4/q, e4/h' }); |
| 14 | + run('Simple(false)', simple, { unison: false, voice1: 'e4/q, e4/q, e4/h', voice2: 'e4/8, e4/8, e4/q, e4/h' }); |
| 15 | + run('Accidentals(true)', simple, { |
| 16 | + unison: true, |
| 17 | + voice1: 'e4/q, e#4/q, e#4/h', |
| 18 | + voice2: 'e4/8, e4/8, eb4/q, eb4/h', |
| 19 | + }); |
| 20 | + run('Accidentals(false)', simple, { |
| 21 | + unison: false, |
| 22 | + voice1: 'e4/q, e#4/q, e#4/h', |
| 23 | + voice2: 'e4/8, e4/8, eb4/q, eb4/h', |
| 24 | + }); |
| 25 | + run('Dots(true)', simple, { unison: true, voice1: 'e4/q.., e4/16, e4/h', voice2: '(a4 e4)/q., e4/8, e4/h' }); |
| 26 | + run('Dots(false)', simple, { unison: false, voice1: 'e4/q.., e4/16, e4/h', voice2: '(a4 e4)/q., e4/8, e4/h' }); |
| 27 | + run('Breve(true)', breve, { unison: true }); |
| 28 | + run('Breve(false)', breve, { unison: false }); |
| 29 | + run('Style(true)', style, { unison: true }); |
| 30 | + run('Style(false)', style, { unison: false }); |
| 31 | + }, |
| 32 | +}; |
| 33 | + |
| 34 | +function simple(options: TestOptions): void { |
| 35 | + Tables.UNISON = options.params.unison; |
| 36 | + const vf = VexFlowTests.makeFactory(options, 500, 200); |
| 37 | + const score = vf.EasyScore(); |
| 38 | + |
| 39 | + const system = vf.System({ y: 40, x: 10, width: 400 }); |
| 40 | + system.addStave({ |
| 41 | + voices: [score.voice(score.notes(options.params.voice1)), score.voice(score.notes(options.params.voice2))], |
| 42 | + }); |
| 43 | + |
| 44 | + system.getStaves()[0].setClef('treble'); |
| 45 | + system.getStaves()[0].setTimeSignature('4/4'); |
| 46 | + vf.draw(); |
| 47 | + expect(0); |
| 48 | +} |
| 49 | + |
| 50 | +function style(options: TestOptions): void { |
| 51 | + Tables.UNISON = options.params.unison; |
| 52 | + const vf = VexFlowTests.makeFactory(options, 500, 200); |
| 53 | + const score = vf.EasyScore(); |
| 54 | + |
| 55 | + const system = vf.System({ y: 40, x: 10, width: 400 }); |
| 56 | + const notes1 = score.notes('e4/q, e4/q, e4/h'); |
| 57 | + const notes2 = score.notes('e4/8, e4/8, e4/q, e4/h'); |
| 58 | + notes1[2].setStyle({ fillStyle: 'blue', strokeStyle: 'blue' }); |
| 59 | + notes2[3].setStyle({ fillStyle: 'green', strokeStyle: 'green' }); |
| 60 | + system.addStave({ |
| 61 | + voices: [score.voice(notes1), score.voice(notes2)], |
| 62 | + }); |
| 63 | + |
| 64 | + system.getStaves()[0].setClef('treble'); |
| 65 | + system.getStaves()[0].setTimeSignature('4/4'); |
| 66 | + vf.draw(); |
| 67 | + expect(0); |
| 68 | +} |
| 69 | + |
| 70 | +function breve(options: TestOptions): void { |
| 71 | + Tables.UNISON = options.params.unison; |
| 72 | + const vf = VexFlowTests.makeFactory(options, 500, 200); |
| 73 | + const score = vf.EasyScore(); |
| 74 | + |
| 75 | + const system = vf.System({ y: 40, x: 10, width: 400 }); |
| 76 | + system.addStave({ |
| 77 | + voices: [ |
| 78 | + score.voice([vf.StaveNote({ keys: ['e/4'], duration: '1/2' })], { time: '8/4' }), |
| 79 | + score.voice(score.notes('e4/1, e4/1'), { time: '8/4' }), |
| 80 | + ], |
| 81 | + }); |
| 82 | + |
| 83 | + system.getStaves()[0].setClef('treble'); |
| 84 | + system.getStaves()[0].setTimeSignature('8/4'); |
| 85 | + vf.draw(); |
| 86 | + expect(0); |
| 87 | +} |
| 88 | + |
| 89 | +VexFlowTests.register(UnisonTests); |
| 90 | +export { UnisonTests }; |
0 commit comments