@@ -5,7 +5,6 @@ import WaveformZoomView from '../src/waveform-zoomview';
5
5
6
6
import sampleJsonData from './data/sample.json' ;
7
7
8
- import WaveformData from 'waveform-data' ;
9
8
import Konva from 'konva' ;
10
9
11
10
const TestAudioContext = window . AudioContext || window . mozAudioContext || window . webkitAudioContext ;
@@ -33,8 +32,8 @@ describe('Peaks', function() {
33
32
} ) ;
34
33
35
34
describe ( 'init' , function ( ) {
36
- context ( 'with valid options ', function ( ) {
37
- it ( 'should invoke callback when initialised' , function ( done ) {
35
+ it ( 'should throw if called without a callback ', function ( ) {
36
+ expect ( function ( ) {
38
37
Peaks . init ( {
39
38
overview : {
40
39
container : document . getElementById ( 'overview-container' )
@@ -44,17 +43,13 @@ describe('Peaks', function() {
44
43
} ,
45
44
mediaElement : document . getElementById ( 'media' ) ,
46
45
dataUri : { arraybuffer : '/base/test/data/sample.dat' }
47
- } ,
48
- function ( err , instance ) {
49
- expect ( err ) . to . equal ( null ) ;
50
- expect ( instance ) . to . be . an . instanceOf ( Peaks ) ;
51
- instance . destroy ( ) ;
52
- done ( ) ;
53
46
} ) ;
54
- } ) ;
47
+ } ) . to . throw ( Error , / c a l l b a c k / ) ;
48
+ } ) ;
55
49
56
- it ( 'should return the peaks instance' , function ( done ) {
57
- const result = Peaks . init ( {
50
+ context ( 'with valid options' , function ( ) {
51
+ it ( 'should invoke callback when initialised' , function ( done ) {
52
+ Peaks . init ( {
58
53
overview : {
59
54
container : document . getElementById ( 'overview-container' )
60
55
} ,
@@ -67,62 +62,27 @@ describe('Peaks', function() {
67
62
function ( err , instance ) {
68
63
expect ( err ) . to . equal ( null ) ;
69
64
expect ( instance ) . to . be . an . instanceOf ( Peaks ) ;
70
- expect ( result ) . to . equal ( instance ) ;
71
65
instance . destroy ( ) ;
72
66
done ( ) ;
73
67
} ) ;
74
68
} ) ;
75
69
76
- it ( 'should emit a peaks.ready event when initialised' , function ( done ) {
77
- const logger = sinon . spy ( ) ;
78
-
79
- Peaks . init ( {
70
+ it ( 'should return the peaks instance' , function ( done ) {
71
+ const result = Peaks . init ( {
80
72
overview : {
81
73
container : document . getElementById ( 'overview-container' )
82
74
} ,
83
75
zoomview : {
84
76
container : document . getElementById ( 'zoomview-container' )
85
77
} ,
86
78
mediaElement : document . getElementById ( 'media' ) ,
87
- dataUri : { arraybuffer : '/base/test/data/sample.dat' } ,
88
- logger : logger
79
+ dataUri : { arraybuffer : '/base/test/data/sample.dat' }
89
80
} ,
90
81
function ( err , instance ) {
91
82
expect ( err ) . to . equal ( null ) ;
92
83
expect ( instance ) . to . be . an . instanceOf ( Peaks ) ;
93
-
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 / ) ;
97
- expect ( instance . getWaveformData ( ) ) . to . be . an . instanceOf ( WaveformData ) ;
98
- done ( ) ;
99
- } ) ;
100
- } ) ;
101
- } ) ;
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 / ) ;
84
+ expect ( result ) . to . equal ( instance ) ;
85
+ instance . destroy ( ) ;
126
86
done ( ) ;
127
87
} ) ;
128
88
} ) ;
0 commit comments