Skip to content

Commit

Permalink
Include tests in linting and clean up linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
oshoham committed May 27, 2019
1 parent 64819c0 commit f5f85b8
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 98 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Gruntfile.js
test/test.js
File renamed without changes.
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module.exports = function(grunt) {
// Configure style consistency
eslint: {
source: {
options: {configFile: './src/.eslintrc'},
src: ['src/**/*.js']
options: {configFile: './.eslintrc'},
src: ['src/**/*.js', 'test/tests/**/*.js']
}
},
watch: {
Expand Down
16 changes: 8 additions & 8 deletions test/tests/p5.Amplitude.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {
var expect = chai.expect;

describe('p5.Amplitude', function() {
this.timeout(1000);

var sf, amp;

it('can be created', function(){
it('can be created', function() {
amp = new p5.Amplitude();
});

after(function(done){
after(function(done) {
expect( amp.getLevel() ).to.not.equal(1.0);
osc.dispose();
sf.dispose();
Expand All @@ -37,7 +37,7 @@ define(['chai'],
});

it('gets normalized osc level', function(done) {
setTimeout(function(cleanup) {
setTimeout(function() {
oAmp.toggleNormalize(true);
// console.log( 'normalized: ' + oAmp.getLevel() );
expect( oAmp.getLevel() ).to.be.closeTo(1.0, 0.4);
Expand All @@ -46,9 +46,9 @@ define(['chai'],
});


it('loop a SoundFile with params, disconnected from master, setInput()', function(done){
it('loop a SoundFile with params, disconnected from master, setInput()', function(done) {
p5.prototype.soundFormats('ogg', 'mp3');
sf = p5.prototype.loadSound('./testAudio/drum', function(){
sf = p5.prototype.loadSound('./testAudio/drum', function() {
sf.disconnect();
sf.loop(1,1,0.0, 0.05);
sf.connect(amp);
Expand All @@ -67,4 +67,4 @@ define(['chai'],
});

});
});
});
9 changes: 5 additions & 4 deletions test/tests/p5.AudioIn.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {

var expect = chai.expect;

describe('p5.AudioIn', function() {
it('can be created and disposed', function(){
it('can be created and disposed', function() {
var mic = new p5.AudioIn();
mic.dispose();
});
Expand All @@ -29,7 +30,7 @@ define(['chai'],
var mic = new p5.AudioIn();
expect(mic.currentSource).to.be.null;

return mic.getSources().then(function(sources) {
return mic.getSources().then(function() {
mic.setSource(0);
expect(mic.currentSource).to.equal(0);
done();
Expand Down
6 changes: 3 additions & 3 deletions test/tests/p5.AudioVoice.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {
var expect = chai.expect;

describe('p5.AudioVoice', function() {
Expand All @@ -12,7 +12,7 @@ define(['chai'],

it('can convert strings to frequency values', function() {
var av = new p5.AudioVoice();
var freq = av._setNote("A4");
var freq = av._setNote('A4');
expect(freq).to.equal(440);
av.dispose();
});
Expand Down
8 changes: 4 additions & 4 deletions test/tests/p5.Compressor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {
var expect = chai.expect;

describe('p5.Compressor', function() {
Expand All @@ -10,12 +10,12 @@ define(['chai'],
compressor.dispose();
});

it('wet dry value can be changed', function(){
it('wet dry value can be changed', function() {
var compressor = new p5.Compressor();
expect(compressor.drywet(0.5)).to.equal(0.5);
});

it('can set params', function(){
it('can set params', function() {
var compressor = new p5.Compressor();
compressor.set(0.5, 20, 15, -50, 0.75);
expect(compressor.attack()).to.equal(0.5);
Expand Down
14 changes: 7 additions & 7 deletions test/tests/p5.Delay.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {

var expect = chai.expect;

Expand All @@ -10,22 +11,21 @@ define(['chai'],
delay.dispose();
});

it('has initial feedback value of 0.5', function(){
it('has initial feedback value of 0.5', function() {
var delay = new p5.Delay();
expect(delay.feedback()).to.equal(0.5);
});

it('can set feedback', function(){
it('can set feedback', function() {
var delay = new p5.Delay();
delay.feedback(0.7);
expect(delay.feedback()).to.be.closeTo(0.7, 0.001);
});

it('drywet value can be changed', function(){
it('drywet value can be changed', function() {
var effect = new p5.Effect();

expect(effect.drywet(0.5)).to.equal(0.5);
});

});
});
});
34 changes: 17 additions & 17 deletions test/tests/p5.Distortion.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
define(['chai'],
function(chai) {
'use strict';

var expect = chai.expect;
define(['chai'], function(chai) {
var expect = chai.expect;

describe('p5.Distortion', function() {
this.timeout(1000);
describe('p5.Distortion', function() {
this.timeout(1000);

var dist = new p5.Distortion();
var dist = new p5.Distortion();

it('can be created and disposed', function() {
var d = new p5.Distortion();
d.dispose();
});
it('can be created and disposed', function() {
var d = new p5.Distortion();
d.dispose();
});

it('can set the amount and oversample', function() {
var initialAmt = dist.getAmount();
var initialOS = dist.getOversample();
dist.set(1000, '4x');
expect(dist.getAmount()).not.equal(initialAmt);
expect(dist.getOversample()).not.equal(initialOS);
});
it('can set the amount and oversample', function() {
var initialAmt = dist.getAmount();
var initialOS = dist.getOversample();
dist.set(1000, '4x');
expect(dist.getAmount()).not.equal(initialAmt);
expect(dist.getOversample()).not.equal(initialOS);
});
});
});
13 changes: 7 additions & 6 deletions test/tests/p5.EQ.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {

var expect = chai.expect;

Expand Down Expand Up @@ -32,7 +33,7 @@ define(['chai'],
});

it('a band can be toggled on and off', function() {
var eq = new p5.EQ(8);
var eq = new p5.EQ(8);
expect(eq.bands[2].biquad.type).to.equal('peaking');
eq.bands[2].toggle();
expect(eq.bands[2].biquad.type).to.equal('allpass');
Expand All @@ -57,12 +58,12 @@ define(['chai'],

it('a bands type can be changed', function() {
var eq = new p5.EQ();
expect(eq.bands[2]._untoggledType=='peaking');
expect(eq.bands[2]._untoggledType).to.equal('peaking');
eq.bands[2].setType('highshelf');
expect(eq.bands[2]._untoggledType=='highshelf');
expect(eq.bands[2]._untoggledType).to.equal('highshelf');
});

it('drywet value can be changed', function(){
it('drywet value can be changed', function() {
var eq = new p5.EQ();
expect(eq.drywet(0.5)).to.equal(0.5);
});
Expand Down
9 changes: 5 additions & 4 deletions test/tests/p5.Effect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {

var expect = chai.expect;

Expand All @@ -14,12 +15,12 @@ define(['chai'],
expect(effect.output).to.equal(undefined);
});

it('drywet value can be changed', function(){
it('drywet value can be changed', function() {
var effect = new p5.Effect();
expect(effect.drywet(0.5)).to.equal(0.5);
});

it('drywet value can be used as getter and setter', function(){
it('drywet value can be used as getter and setter', function() {
var effect = new p5.Effect();
expect(effect.drywet(0.5)).to.equal(0.5);
expect(effect.drywet()).to.equal(0.5);
Expand Down
4 changes: 2 additions & 2 deletions test/tests/p5.FFT.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {
var expect = chai.expect;

describe('p5.FFT', function() {
Expand Down
9 changes: 5 additions & 4 deletions test/tests/p5.Filter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {

var expect = chai.expect;

Expand All @@ -10,12 +11,12 @@ define(['chai'],
filter.dispose();
});

it('has initial drywet value of 0.5', function(){
it('has initial drywet value of 0.5', function() {
var filter = new p5.Filter();
expect(filter.drywet(0.5)).to.equal(0.5);
});

it('audio can be processed', function(){
it('audio can be processed', function() {
var filter = new p5.Filter();
var sound = new p5.SoundFile('./testAudio/drum.mp3');
filter.process(sound, 500, 5);
Expand Down
5 changes: 3 additions & 2 deletions test/tests/p5.MonoSynth.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {

var expect = chai.expect;

Expand Down
11 changes: 5 additions & 6 deletions test/tests/p5.Oscillator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {

var expect = chai.expect;

Expand All @@ -18,7 +19,7 @@ define(['chai'],
o.dispose();
});

it('starts and stops', function(done){
it('starts and stops', function(done) {
expect(osc.started).to.equal(false);
osc.start();
expect(osc.started).to.equal(true);
Expand All @@ -28,7 +29,7 @@ define(['chai'],
}, 100);
});

it('can be scheduled to stop', function(done){
it('can be scheduled to stop', function(done) {
osc.stop();
expect(osc.started).to.equal(false);
osc.start();
Expand Down Expand Up @@ -86,7 +87,5 @@ define(['chai'],
}, 55);
});



});
});
5 changes: 3 additions & 2 deletions test/tests/p5.PolySynth.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(['chai'],
function(chai) {
'use strict';

define(['chai'], function(chai) {

var expect = chai.expect;

Expand Down
Loading

0 comments on commit f5f85b8

Please sign in to comment.