@@ -5,18 +5,23 @@ import type { Sound } from '../types';
55describe ( funcs . make_sound , ( ) => {
66 it ( 'Should error gracefully when duration is negative' , ( ) => {
77 expect ( ( ) => funcs . make_sound ( ( ) => 0 , - 1 ) )
8- . toThrow ( 'Sound duration must be greater than or equal to 0' ) ;
8+ . toThrow ( 'make_sound: Sound duration must be greater than or equal to 0' ) ;
99 } ) ;
1010
1111 it ( 'Should not error when duration is zero' , ( ) => {
1212 expect ( ( ) => funcs . make_sound ( ( ) => 0 , 0 ) ) . not . toThrow ( ) ;
1313 } ) ;
14+
15+ it ( 'Should error gracefully when wave is not a function' , ( ) => {
16+ expect ( ( ) => funcs . make_sound ( true as any , 1 ) )
17+ . toThrow ( 'make_sound expects a wave, got true' ) ;
18+ } ) ;
1419} ) ;
1520
1621describe ( funcs . play , ( ) => {
1722 it ( 'Should error gracefully when duration is negative' , ( ) => {
18- const sound = [ ( ) => 0 , - 1 ] ;
19- expect ( ( ) => funcs . play ( sound as any ) )
23+ const sound : Sound = [ ( ) => 0 , - 1 ] ;
24+ expect ( ( ) => funcs . play ( sound ) )
2025 . toThrow ( 'play: duration of sound is negative' ) ;
2126 } ) ;
2227
@@ -30,6 +35,23 @@ describe(funcs.play, () => {
3035 } ) ;
3136} ) ;
3237
38+ describe ( funcs . play_wave , ( ) => {
39+ it ( 'Should error gracefully when duration is negative' , ( ) => {
40+ expect ( ( ) => funcs . play_wave ( ( ) => 0 , - 1 ) )
41+ . toThrow ( 'play_wave: Sound duration must be greater than or equal to 0' ) ;
42+ } ) ;
43+
44+ it ( 'Should error gracefully when duration is not a number' , ( ) => {
45+ expect ( ( ) => funcs . play_wave ( ( ) => 0 , true as any ) )
46+ . toThrow ( 'play_wave expects a number for duration, got true' ) ;
47+ } ) ;
48+
49+ it ( 'Should error gracefully when wave is not a function' , ( ) => {
50+ expect ( ( ) => funcs . play_wave ( true as any , 0 ) )
51+ . toThrow ( 'play_wave expects a wave, got true' ) ;
52+ } ) ;
53+ } ) ;
54+
3355describe ( funcs . play_in_tab , ( ) => {
3456 it ( 'Should error gracefully when duration is negative' , ( ) => {
3557 const sound = [ ( ) => 0 , - 1 ] ;
0 commit comments