@@ -74,6 +74,8 @@ describe('Peaks', function() {
74
74
} ) ;
75
75
76
76
it ( 'should emit a peaks.ready event when initialised' , function ( done ) {
77
+ const logger = sinon . spy ( ) ;
78
+
77
79
Peaks . init ( {
78
80
overview : {
79
81
container : document . getElementById ( 'overview-container' )
@@ -82,19 +84,49 @@ describe('Peaks', function() {
82
84
container : document . getElementById ( 'zoomview-container' )
83
85
} ,
84
86
mediaElement : document . getElementById ( 'media' ) ,
85
- dataUri : { arraybuffer : '/base/test/data/sample.dat' }
87
+ dataUri : { arraybuffer : '/base/test/data/sample.dat' } ,
88
+ logger : logger
86
89
} ,
87
90
function ( err , instance ) {
88
91
expect ( err ) . to . equal ( null ) ;
89
92
expect ( instance ) . to . be . an . instanceOf ( Peaks ) ;
90
93
91
94
instance . on ( 'peaks.ready' , function ( ) {
95
+ expect ( logger . callCount ) . to . equal ( 1 ) ;
96
+ expect ( logger ) . calledWithMatch ( / d e p r e c a t e d / ) ;
92
97
expect ( instance . getWaveformData ( ) ) . to . be . an . instanceOf ( WaveformData ) ;
93
98
done ( ) ;
94
99
} ) ;
95
100
} ) ;
96
101
} ) ;
97
102
103
+ it ( 'should emit a peaks.ready event when initialised without a callback' , function ( done ) {
104
+ const logger = sinon . spy ( ) ;
105
+
106
+ const instance = Peaks . init ( {
107
+ overview : {
108
+ container : document . getElementById ( 'overview-container' )
109
+ } ,
110
+ zoomview : {
111
+ container : document . getElementById ( 'zoomview-container' )
112
+ } ,
113
+ mediaElement : document . getElementById ( 'media' ) ,
114
+ dataUri : { arraybuffer : '/base/test/data/sample.dat' } ,
115
+ logger : logger
116
+ } ) ;
117
+
118
+ expect ( instance ) . to . be . an . instanceOf ( Peaks ) ;
119
+
120
+ expect ( logger . callCount ) . to . equal ( 1 ) ;
121
+
122
+ instance . on ( 'peaks.ready' , function ( ) {
123
+ expect ( logger . callCount ) . to . equal ( 2 ) ;
124
+ expect ( logger . getCall ( 0 ) . args [ 0 ] ) . to . match ( / c a l l b a c k / ) ;
125
+ expect ( logger . getCall ( 1 ) . args [ 0 ] ) . to . match ( / d e p r e c a t e d / ) ;
126
+ done ( ) ;
127
+ } ) ;
128
+ } ) ;
129
+
98
130
context ( 'with zoomview and overview options' , function ( ) {
99
131
it ( 'should construct a Peaks object with overview and zoomable waveforms' , function ( done ) {
100
132
Peaks . init ( {
0 commit comments