@@ -732,12 +732,19 @@ if (typeof window !== 'undefined') {
732732 }
733733
734734 describe ( 'with a cycle' , ( ) => {
735+ let delay ;
735736 let renderer ;
736737
737738 beforeEach ( ( ) => {
739+ delay = 128 ;
740+
741+ if ( description . includes ( 'Offline' ) ) {
742+ context = createContext ( { length : delay + 5 } ) ;
743+ }
744+
738745 renderer = createRenderer ( {
739746 context,
740- length : context . length === undefined ? 5 : undefined ,
747+ length : context . length === undefined ? delay + 5 : undefined ,
741748 setup ( destination ) {
742749 const constantSourceNode = new ConstantSourceNode ( context ) ;
743750 const delayNode = createDelayNode ( context ) ;
@@ -747,7 +754,7 @@ if (typeof window !== 'undefined') {
747754 * Bug #164: Only Firefox detects cycles and therefore is the only browser which clamps the delayTime to
748755 * the minimum amount.
749756 */
750- delayNode . delayTime . value = 128 / context . sampleRate ;
757+ delayNode . delayTime . value = delay / context . sampleRate ;
751758
752759 constantSourceNode . connect ( delayNode ) . connect ( destination ) ;
753760
@@ -758,15 +765,19 @@ if (typeof window !== 'undefined') {
758765 } ) ;
759766 } ) ;
760767
761- it ( 'should render silence ' , function ( ) {
768+ it ( 'should render a delayed signal ' , function ( ) {
762769 this . timeout ( 10000 ) ;
763770
764771 return renderer ( {
765772 start ( startTime , { constantSourceNode } ) {
766773 constantSourceNode . start ( startTime ) ;
767774 }
768775 } ) . then ( ( channelData ) => {
769- expect ( Array . from ( channelData ) ) . to . deep . equal ( [ 0 , 0 , 0 , 0 , 0 ] ) ;
776+ for ( let i = 0 ; i < delay ; i += 1 ) {
777+ expect ( channelData [ i ] ) . to . be . closeTo ( 0 , 0.000003 ) ;
778+ }
779+
780+ expect ( Array . from ( channelData ) . slice ( delay ) ) . to . deep . equal ( [ 1 , 1 , 1 , 1 , 1 ] ) ;
770781 } ) ;
771782 } ) ;
772783 } ) ;
0 commit comments