Skip to content

Commit

Permalink
Merge pull request #1067 from ronyeh/migration/vexflow_test_helpers
Browse files Browse the repository at this point in the history
Migrate vexflow_test_helpers
  • Loading branch information
0xfe authored Jul 25, 2021
2 parents 3eea242 + 4ca4a7c commit 2315e7a
Show file tree
Hide file tree
Showing 8 changed files with 386 additions and 311 deletions.
4 changes: 1 addition & 3 deletions src/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ export abstract class Note extends Tickable {
return 'note';
}

/** Debug helper. Displays various note metrics for the given
* note.
*/
/** Debug helper. Displays various note metrics for the given note. */
static plotMetrics(ctx: RenderContext, note: Note, yPos: number): void {
const metrics = note.getMetrics();
const xStart = note.getAbsoluteX() - metrics.modLeftPx - metrics.leftDisplacedHeadPx;
Expand Down
3 changes: 3 additions & 0 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { SVGContext } from './svgcontext';
import { RenderContext } from './types/common';
import { RuntimeError } from './util';

// A ContextBuilder is either Renderer.getSVGContext or Renderer.getCanvasContext.
export type ContextBuilder = typeof Renderer.getSVGContext | typeof Renderer.getCanvasContext;

/**
* Support Canvas & SVG rendering contexts.
*/
Expand Down
6 changes: 1 addition & 5 deletions tests/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const notStrictEqual = global.notStrictEqual;
// TODO: npm install @types/qunit
/* eslint-disable @typescript-eslint/no-explicit-any */
export interface Assert {
test: any;
expect(amount: number): void;
ok(state: any, message?: string): void;
notOk(state: any, message?: string): void;
Expand All @@ -44,8 +45,3 @@ export interface Assert {
raises(block: () => void, expected?: any, message?: any): void;
}
/* eslint-enable @typescript-eslint/no-explicit-any */

// See: vexflow_test_helpers.
export interface TestOptions {
assert: Assert;
}
33 changes: 15 additions & 18 deletions tests/easyscore_tests.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
/**
* VexFlow - EasyScore Tests
* Copyright Mohit Muthanna 2010 <mohit@muthanna.com>
*/
// [VexFlow](https://vexflow.com/) - Copyright (c) Mohit Muthanna 2010.
// MIT License
//
// EasyScore Tests

import { EasyScore } from '../src/easyscore';
import { StaveNote } from '../src/stavenote';
import { System } from '../src/system';
import { FretHandFinger } from '../src/frethandfinger';
import { QUnit, expect, Assert, TestOptions } from './declarations';
import { QUnit, expect, Assert } from './declarations';
import { Articulation } from '../src/articulation';
import { VexFlowTests, TestOptions } from './vexflow_test_helpers';

// eslint-disable-next-line
declare const VF: any; // TODO: Remove after migrating vexflow_test_helpers.js.
// eslint-disable-next-line
declare let Vex: any; // TODO: Remove after migrating vex.js.
declare const VF: any; // TODO: Remove soon!

const EasyScoreTests = {
Start: function (): void {
const VFT = Vex.Flow.Test;
QUnit.module('EasyScore');
QUnit.test('Basic', EasyScoreTests.basic);
QUnit.test('Accidentals', EasyScoreTests.accidentals);
QUnit.test('Durations', EasyScoreTests.durations);
QUnit.test('Chords', EasyScoreTests.chords);
QUnit.test('Dots', EasyScoreTests.dots);
QUnit.test('Options', EasyScoreTests.options);
VFT.runTests('Draw Basic', EasyScoreTests.drawBasicTest);
VFT.runTests('Draw Accidentals', EasyScoreTests.drawAccidentalsTest);
VFT.runTests('Draw Beams', EasyScoreTests.drawBeamsTest);
VFT.runTests('Draw Tuplets', EasyScoreTests.drawTupletsTest);
VFT.runTests('Draw Dots', EasyScoreTests.drawDotsTest);
VFT.runTests('Draw Options', EasyScoreTests.drawOptionsTest);
VFT.runTests('Draw Fingerings', EasyScoreTests.drawFingeringsTest);
VexFlowTests.runTests('Draw Basic', EasyScoreTests.drawBasicTest);
VexFlowTests.runTests('Draw Accidentals', EasyScoreTests.drawAccidentalsTest);
VexFlowTests.runTests('Draw Beams', EasyScoreTests.drawBeamsTest);
VexFlowTests.runTests('Draw Tuplets', EasyScoreTests.drawTupletsTest);
VexFlowTests.runTests('Draw Dots', EasyScoreTests.drawDotsTest);
VexFlowTests.runTests('Draw Options', EasyScoreTests.drawOptionsTest);
VexFlowTests.runTests('Draw Fingerings', EasyScoreTests.drawFingeringsTest);
},

basic: function (assert: Assert): void {
Expand Down Expand Up @@ -411,6 +410,4 @@ const EasyScoreTests = {
},
};

// Vex.Flow.Test.EasyScore = EasyScoreTests;

export { EasyScoreTests };
2 changes: 1 addition & 1 deletion tests/stavenote_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const StaveNoteTests = (function () {
test('Width', StaveNote.width);
test('TickContext', StaveNote.tickContext);

VF.Test.runUITests('Interactive Mouseover StaveNote', StaveNote.draw, {
VF.Test.runSVGTest('Interactive Mouseover StaveNote', StaveNote.draw, {
clef: 'treble',
octaveShift: 0,
restKey: 'r/4',
Expand Down
278 changes: 0 additions & 278 deletions tests/vexflow_test_helpers.js

This file was deleted.

Loading

0 comments on commit 2315e7a

Please sign in to comment.