Skip to content

Commit

Permalink
added unit test for p5.gain in es6
Browse files Browse the repository at this point in the history
  • Loading branch information
endurance21 committed Jun 6, 2020
1 parent 4150c88 commit dc10fda
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ require.config({

var allTests = [
'tests/p5.Master',
'tests/p5.Gain',
'tests/p5.SoundFile',
'tests/p5.Amplitude',
'tests/p5.Oscillator',
'tests/p5.Distortion',
'tests/p5.Effect',
Expand Down
51 changes: 51 additions & 0 deletions test/tests/p5.Gain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict '

define(['chai'],(chai)=>{
const expect = chai.expect ;
describe('P5.Gain',()=>{
it('can be initilized and disposed',()=>{
let gain = new p5.Gain();
gain.dispose();
});
it('can set input', ()=>{
let inputNode = new p5.Gain();
let mainGainNode = new p5.Gain();

mainGainNode.setInput(inputNode);
});
it('can send output',()=>{
let outputNode = new p5.Gain();
let mainGainNode = new p5.Gain();

mainGainNode.connect(outputNode);
});
it('can disconnect all output' ,()=>{
let inputNode = new p5.Gain();
let outputNode = new p5.Gain();
let mainGainNode = new p5.Gain();

mainGainNode.setInput(inputNode);
mainGainNode.connect(outputNode);
mainGainNode.disconnect();
});
it('can set the output level of gain Node', ()=>{
let osc = new p5.Oscillator('sine');
let mainGainNode = new p5.Gain();
let amplitude = new p5.Amplitude();

osc.amp(1);
osc.start();
osc.disconnect();

mainGainNode.setInput(osc);
amplitude.setInput(mainGainNode);

mainGainNode.amp(0.5);
setTimeout(function() {
expect( amplitude.getLevel() ).to.be.closeTo(0.25, 0.125);
}, 100);

})
});

}) ;

0 comments on commit dc10fda

Please sign in to comment.