Skip to content

Commit

Permalink
Added test/coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Apr 11, 2024
1 parent e5b06ae commit dd93247
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- run: npm install
- run: npm test
- run: npm run coverage
- uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion javascript/JZZ.input.Kbd.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if (!JZZ) return;
if (!JZZ.input) JZZ.input = {};

var _version = '1.2.8';
var _version = '1.3.0';
function _name(name, deflt) { return name ? name : deflt; }

function _copy(obj) {
Expand Down
2 changes: 1 addition & 1 deletion minified/JZZ.input.Kbd.js

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "jzz-input-kbd",
"version": "1.2.9",
"version": "1.3.0",
"description": "Virtual piano controls for your MIDI projects",
"main": "javascript/JZZ.input.Kbd.js",
"scripts": {
"lint": "eslint javascript"
"test": "nyc instrument ./javascript ./test/.instrumented && nyc mocha",
"lint": "eslint javascript test",
"coverage": "nyc report --reporter=lcov"
},
"keywords": [
"midi",
Expand All @@ -17,14 +19,18 @@
],
"author": "jazz-soft (https://jazz-soft.net/)",
"dependencies": {
"jzz": "^1.7.8"
"jzz": "^1.8.1"
},
"devDependencies": {
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"grunt": "^1.6.1",
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-uglify": "^5.2.2",
"jzz-synth-tiny": "^1.3.8"
"jsdom": "^24.0.0",
"jzz-synth-tiny": "^1.3.9",
"mocha": "^10.4.0",
"nyc": "^15.1.0",
"web-midi-test": "^1.2.7"
},
"repository": {
"type": "git",
Expand Down
19 changes: 19 additions & 0 deletions test/.instrumented/JZZ.input.Kbd.js

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions test/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang=en>
<head>
<title>JZZ-input-Kbd Test</title>
<script src="../node_modules/jzz/javascript/JZZ.js"></script>
<script src=".instrumented/JZZ.input.Kbd.js"></script>
<script src=".instrumented/JZZ.input.Kbd.js"></script>
</head>

<body>

<h1>JZZ-input-Kbd Test</h1>
<p id=kbd1></p>
<p id=kbd2></p>

<script><!--

--></script>

</body>
</html>
35 changes: 35 additions & 0 deletions test/mocha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const assert = require('assert');
const JSDOM = require('jsdom').JSDOM;
const WMT = require('web-midi-test');

var midi_out = new WMT.MidiDst('VIRTUAL MIDI-Out');
midi_out.connect();

global.__coverage__ = {};

describe('In browser', function() {
before(function() {
return new Promise(function(resolve) {
JSDOM.fromFile('test/demo.html', {
resources: 'usable',
runScripts: 'dangerously',
beforeParse: function(window) {
window.__coverage__ = global.__coverage__;
window.navigator.requestMIDIAccess = WMT.requestMIDIAccess;
}
}).then(function(dom) {
global.window = dom.window;
setTimeout(resolve, 1500);
});
});
});
it('it works!', function() {
assert.equal(0, 0);
});
after(function() {
try {
global.window.close();
}
catch(e) { console.log(e); }
});
});

0 comments on commit dd93247

Please # to comment.