Skip to content

Commit

Permalink
Added JZZ.Widget test
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Aug 20, 2018
1 parent b36242c commit 9b51a6c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ catch(err) {
console.log('midi-test module is disabled in this configuration');
}

function Sample(done, list) {
this.done = done;
this.list = list.slice();
this.count = 0;
this.compare = function(msg) {
if (this.count < this.list.length) assert.equal(msg.slice().toString(), this.list[this.count].toString());
this.count++;
if (this.count == this.list.length) this.done();
};
}

describe('MIDI messages', function() {
it('empty', function() {
assert.equal(JZZ.MIDI().toString(), 'empty');
Expand Down Expand Up @@ -263,6 +274,19 @@ describe('JZZ.lib', function() {
});
});

describe('JZZ.Widget', function() {
it('ch', function(done) {
var sample = new Sample(done, [[0x91, 0x3c, 0x7f], [0x82, 0x3c, 0x7f]]);
var port = JZZ.Widget({ _receive: function(msg) { sample.compare(msg); }});
port.ch(1).noteOn('C5').ch(2).noteOff('C5', 127);
});
it.skip('mpe', function(done) {
var sample = new Sample(done, [[0xc0, 0x19], [0x90, 0x3c, 0x7f], [0x90, 0x3c, 0x7f]]);
var port = JZZ.Widget({ _receive: function(msg) { sample.compare(msg); }});
port.mpe(0, 4).noteOn('C5').noteOn('D5');
});
});

describe('Engine', function() {
it('JZZ()', function(done) {
JZZ().and(function() { console.log(this.info()); done(); });
Expand Down

0 comments on commit 9b51a6c

Please sign in to comment.