-
Notifications
You must be signed in to change notification settings - Fork 668
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Command line QUnit test uses flow-headless-browser.html instead (it's
much simpler).
- Loading branch information
Showing
4 changed files
with
99 additions
and
91 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<div id="vexflow_testoutput"></div> | ||
<script src="support/qunit.js"></script> | ||
<script src="../build/vexflow-tests.js"></script> | ||
<script> | ||
QUnit.config.noglobals = true; | ||
Vex.Flow.Test.run(); | ||
</script> | ||
</body> | ||
</html> |
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 |
---|---|---|
|
@@ -4,7 +4,27 @@ | |
<title>VexFlow - JavaScript Music Notation and Guitar Tab</title> | ||
<link rel="stylesheet" href="flow.css" type="text/css" media="screen" /> | ||
<link rel="stylesheet" href="support/qunit.css" type="text/css" media="screen" /> | ||
<script src="support/jquery.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div style="text-align: center"> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<div> | ||
<h2>[ <a href="http://vexflow.com">Home</a> ] [ <a href="http://github.com/0xfe/vexflow">GitHub</a> ]</h2> | ||
<h3> | ||
See the: <a id="vex-src" target="_blank"></a>. Don't forget to run the | ||
<a href="https://github.com/0xfe/vexflow/wiki/Visual-Regression-Tests">Visual Regression Tests</a>! | ||
</h3> | ||
</div> | ||
<p> </p> | ||
<div id="vexflow_testoutput"></div> | ||
<p> </p> | ||
<p class="vf-footer"> | ||
[ <a href="http://vexflow.com">home</a> ] [ <a href="http://github.com/0xfe/vexflow">github</a> ] [ | ||
<a href="http://0xfe.muthanna.com">0xfe</a> ] | ||
</p> | ||
</div> | ||
<script> | ||
function loadScript(url) { | ||
return new Promise((resolve, reject) => { | ||
|
@@ -19,90 +39,70 @@ | |
}); | ||
} | ||
|
||
$(function () { | ||
// Support a query param to choose which VexFlow version to load. | ||
// ver=(build|reference|releases|etc...) | ||
// If omitted, ver defaults to 'build'. | ||
var params = new URLSearchParams(window.location.search); | ||
var param_ver = params.get('ver'); | ||
// Support a query param to choose which VexFlow version to load. | ||
// ver=(build|reference|releases|etc...) | ||
// If omitted, ver defaults to 'build'. | ||
var params = new URLSearchParams(window.location.search); | ||
var param_ver = params.get('ver'); | ||
|
||
var vexURL; | ||
var testsURL; | ||
var isCurrentBuild = false; | ||
var vexURL; | ||
var testsURL; | ||
var isCurrentBuild = false; | ||
|
||
// ver can also specify a version hosted on unpkg.com: | ||
// [email protected] or [email protected] | ||
// https://unpkg.com/[email protected]/releases/vexflow-debug.js | ||
if (param_ver && param_ver.includes('unpkg')) { | ||
var version = param_ver.split('@')[1]; | ||
vexURL = `https://unpkg.com/vexflow@${version}/releases/vexflow-debug.js`; | ||
testsURL = `https://unpkg.com/vexflow@${version}/releases/vexflow-tests.js`; | ||
} else { | ||
var path = param_ver || 'build'; | ||
if (path === 'build') { | ||
isCurrentBuild = true; | ||
} | ||
vexURL = '../' + path + '/vexflow-debug.js'; | ||
testsURL = '../' + path + '/vexflow-tests.js'; | ||
// `ver` can also specify a version hosted on unpkg.com: | ||
// [email protected] or [email protected] | ||
// https://unpkg.com/[email protected]/releases/vexflow-debug.js | ||
if (param_ver && param_ver.includes('unpkg')) { | ||
var version = param_ver.split('@')[1]; | ||
vexURL = `https://unpkg.com/vexflow@${version}/releases/vexflow-debug.js`; | ||
testsURL = `https://unpkg.com/vexflow@${version}/releases/vexflow-tests.js`; | ||
} else { | ||
var path = param_ver || 'build'; | ||
if (path === 'build') { | ||
isCurrentBuild = true; | ||
} | ||
vexURL = '../' + path + '/vexflow-debug.js'; | ||
testsURL = '../' + path + '/vexflow-tests.js'; | ||
} | ||
|
||
// Display which VexFlow version we loaded, if the `ver` param was specified. | ||
var info = param_ver !== null ? ` [${param_ver}]` : ''; | ||
$('#vex-src') | ||
.attr('href', vexURL) | ||
.text('VexFlow Source' + info); | ||
// Display which VexFlow version we loaded, if the `ver` param was specified. | ||
var info = param_ver !== null ? ` [${param_ver}]` : ''; | ||
const srcLink = document.getElementById('vex-src'); | ||
srcLink.href = vexURL; | ||
srcLink.innerText = 'VexFlow Source' + info; | ||
|
||
// When loading the current version, only load vexflow-tests.js | ||
// When loading old versions, load both vexflow-debug.js and vexflow-tests.js | ||
let loadVexFlowTests; | ||
if (isCurrentBuild) { | ||
loadVexFlowTests = () => loadScript(testsURL); | ||
} else { | ||
loadVexFlowTests = () => loadScript(vexURL).then(() => loadScript(testsURL)); | ||
} | ||
let loadVexFlow; | ||
if (isCurrentBuild) { | ||
// When loading version >= 4.0.0, only load vexflow-tests.js | ||
loadVexFlow = () => loadScript(testsURL); | ||
} else { | ||
// When loading versions <= 3.0.9, load both vexflow-debug.js and vexflow-tests.js | ||
loadVexFlow = () => loadScript(vexURL).then(() => loadScript(testsURL)); | ||
} | ||
|
||
const fontServer = 'https://unpkg.com/[email protected]/'; | ||
const getFontURLs = (pathToWoff) => | ||
`url(${fontServer}${pathToWoff}2) format('woff2'), url(${fontServer}${pathToWoff}) format('woff')`; | ||
const robotoFont = new FontFace('Roboto Slab', getFontURLs('robotoslab/RobotoSlab-Medium_2.001.woff')); | ||
const petalumaFont = new FontFace('PetalumaScript', getFontURLs('petaluma/PetalumaScript_1.10.woff')); | ||
// Load web fonts before running the tests. | ||
const host = 'https://unpkg.com/[email protected]/'; | ||
const srcURLs = (path) => `url(${host}${path}2) format('woff2'), url(${host}${path}) format('woff')`; | ||
const robotoFont = new FontFace('Roboto Slab', srcURLs('robotoslab/RobotoSlab-Medium_2.001.woff')); | ||
const petalumaFont = new FontFace('PetalumaScript', srcURLs('petaluma/PetalumaScript_1.10.woff')); | ||
|
||
loadVexFlowTests() | ||
.then(() => robotoFont.load()) | ||
.then(() => petalumaFont.load()) | ||
.then(() => { | ||
document.fonts.add(robotoFont); | ||
document.fonts.add(petalumaFont); | ||
}) | ||
.then(() => loadScript('support/qunit.js')) | ||
.then(() => { | ||
// Show only failed tests. | ||
QUnit.config.hidepassed = true; | ||
QUnit.config.noglobals = true; | ||
Vex.Flow.Test.run(); | ||
}); | ||
}); | ||
loadVexFlow() | ||
.then(() => robotoFont.load()) | ||
.then(() => petalumaFont.load()) | ||
.then(() => { | ||
document.fonts.add(robotoFont); | ||
document.fonts.add(petalumaFont); | ||
}) | ||
// Load qunit.js as late as possible to avoid a race condition | ||
// where the QUnit module drop down box doesn't appear if | ||
// Vex.Flow.Test.run() happens too late, | ||
.then(() => loadScript('support/qunit.js')) | ||
.then(() => { | ||
// Show only failed tests. | ||
QUnit.config.hidepassed = true; | ||
QUnit.config.noglobals = true; | ||
Vex.Flow.Test.run(); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<div style="text-align: center"> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<div> | ||
<h2>[ <a href="http://vexflow.com">Home</a> ] [ <a href="http://github.com/0xfe/vexflow">GitHub</a> ]</h2> | ||
<h3> | ||
See the: <a id="vex-src" target="_blank"></a>. Don't forget to run the | ||
<a href="https://github.com/0xfe/vexflow/wiki/Visual-Regression-Tests">Visual Regression Tests</a>! | ||
</h3> | ||
</div> | ||
<p> </p> | ||
<div id="vexflow_testoutput"></div> | ||
<p> </p> | ||
<p class="vf-footer"> | ||
[ <a href="http://vexflow.com">home</a> ] [ <a href="http://github.com/0xfe/vexflow">github</a> ] [ | ||
<a href="http://0xfe.muthanna.com">0xfe</a> ] | ||
</p> | ||
</div> | ||
</body> | ||
</html> |