File tree Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 1
1
import ( './tests/p5.Master.js' ) ;
2
+ import ( './tests/p5.Helpers.js' ) ;
2
3
import ( './tests/p5.Distortion.js' ) ;
3
4
import ( './tests/p5.Effect.js' ) ;
4
5
import ( './tests/p5.Filter.js' ) ;
@@ -10,6 +11,6 @@ import('./tests/p5.AudioVoice.js');
10
11
import ( './tests/p5.MonoSynth.js' ) ;
11
12
import ( './tests/p5.PolySynth.js' ) ;
12
13
import ( './tests/p5.SoundRecorder.js' ) ;
13
- import ( './tests/p5.SoundFile.js' )
14
- import ( './tests/p5.Amplitude.js' )
15
- import ( './tests/p5.Oscillator.js' )
14
+ import ( './tests/p5.SoundFile.js' ) ;
15
+ import ( './tests/p5.Amplitude.js' ) ;
16
+ import ( './tests/p5.Oscillator.js' ) ;
Original file line number Diff line number Diff line change
1
+ const expect = chai . expect ;
2
+
3
+ describe ( 'Testing helpers function' , function ( ) {
4
+ it ( 'p5.prototype.freqToMidi helper function' , function ( ) {
5
+ const midi = p5 . prototype . freqToMidi ( 880 ) ;
6
+ expect ( midi ) . to . equal ( 81 ) ;
7
+ } ) ;
8
+
9
+ it ( 'p5.prototype.midiToFreq helper function' , function ( ) {
10
+ const freq = p5 . prototype . midiToFreq ( 100 ) ;
11
+ expect ( freq ) . to . equal ( 2637.0204553029594 ) ;
12
+ } ) ;
13
+
14
+ it ( 'p5.prototype.noteToFreq helper function' , function ( ) {
15
+ const freq = p5 . prototype . noteToFreq ( 'C4' ) ;
16
+ expect ( freq ) . to . equal ( 261.6255653005986 ) ;
17
+ } ) ;
18
+
19
+ it ( 'p5.prototype.soundFormats helper function' , function ( ) {
20
+ // setting file format so that if we don't provide extension
21
+ // our file will be loaded because _checkFileFormats add it for us.
22
+
23
+ p5 . prototype . soundFormats ( 'mp3' ) ;
24
+ const file = p5 . prototype . _checkFileFormats ( 'a' ) ;
25
+ expect ( file ) . to . be . equal ( 'a.mp3' ) ;
26
+
27
+ // if we don't provide a valid sound format then soundFormats wil throw
28
+ //error
29
+ try {
30
+ p5 . prototype . soundFormats ( 'ext' ) ;
31
+ } catch ( err ) {
32
+ expect ( err ) . to . be . equal ( 'ext is not a valid sound format!' ) ;
33
+ }
34
+ } ) ;
35
+ } ) ;
You can’t perform that action at this time.
0 commit comments