@@ -172,8 +172,12 @@ describe('external event-based API', () => {
172
172
player . play ( ) . then ( ( ) => {
173
173
const annotation = plugin . annotationState . annotations [ 0 ] ;
174
174
const { commentList } = annotation ;
175
+ plugin . fire ( 'newComment' , {
176
+ annotationId : annotation . id ,
177
+ body : 'My new comment'
178
+ } ) ;
175
179
const startingLength = commentList . comments . length ;
176
- const commentId = commentList . comments [ 0 ] . id ;
180
+ const commentId = commentList . comments [ startingLength - 1 ] . id ;
177
181
plugin . fire ( 'destroyComment' , { id : commentId } ) ;
178
182
179
183
expect ( commentList . comments . length ) . to . equal ( startingLength - 1 ) ;
@@ -193,7 +197,7 @@ describe('external event-based API', () => {
193
197
it ( 'is triggered when plugin state is changed' , done => {
194
198
const plugin = simplePluginSetup ( ) ;
195
199
196
- plugin . on ( 'onStateChanged' , event => {
200
+ plugin . registerListener ( 'onStateChanged' , event => {
197
201
expect ( event . detail [ 0 ] . id ) . to . equal ( 2 ) ;
198
202
done ( ) ;
199
203
} ) ;
@@ -211,7 +215,7 @@ describe('external event-based API', () => {
211
215
it ( 'is triggered when comment is deleted' , done => {
212
216
const plugin = simplePluginSetup ( ) ;
213
217
214
- plugin . on ( 'annotationDeleted' , event => {
218
+ plugin . registerListener ( 'annotationDeleted' , event => {
215
219
expect ( event . detail . id ) . to . equal ( 2 ) ;
216
220
done ( ) ;
217
221
} ) ;
@@ -233,7 +237,7 @@ describe('external event-based API', () => {
233
237
const plugin = simplePluginSetup ( ) ;
234
238
235
239
// Add listener
236
- plugin . on ( 'annotationOpened' , event => {
240
+ plugin . registerListener ( 'annotationOpened' , event => {
237
241
expect ( event . detail . triggered_by_timeline ) . to . equal ( false ) ;
238
242
expect ( event . detail . annotation . id ) . to . equal ( 1 ) ;
239
243
expect ( event . detail . annotation . range . end ) . to . equal ( 60 ) ;
@@ -258,7 +262,7 @@ describe('external event-based API', () => {
258
262
const plugin = simplePluginSetup ( ) ;
259
263
260
264
// Add listener
261
- plugin . on ( 'annotationOpened' , event => {
265
+ plugin . registerListener ( 'annotationOpened' , event => {
262
266
expect ( event . detail . triggered_by_timeline ) . to . equal ( true ) ;
263
267
expect ( event . detail . annotation . id ) . to . equal ( 1 ) ;
264
268
expect ( event . detail . annotation . range . end ) . to . equal ( 60 ) ;
@@ -285,7 +289,7 @@ describe('external event-based API', () => {
285
289
const plugin = simplePluginSetup ( ) ;
286
290
287
291
// Add listener
288
- plugin . on ( 'addingAnnotationDataChanged' , event => {
292
+ plugin . registerListener ( 'addingAnnotationDataChanged' , event => {
289
293
expect ( event . detail . shape ) . to . not . be . undefined ;
290
294
done ( ) ;
291
295
} ) ;
@@ -321,7 +325,7 @@ describe('external event-based API', () => {
321
325
const plugin = simplePluginSetup ( ) ;
322
326
323
327
// Add listener
324
- plugin . on ( 'addingAnnotationDataChanged' , event => {
328
+ plugin . registerListener ( 'addingAnnotationDataChanged' , event => {
325
329
expect ( event . detail . range ) . to . not . be . undefined ;
326
330
done ( ) ;
327
331
} ) ;
@@ -347,7 +351,7 @@ describe('external event-based API', () => {
347
351
const plugin = simplePluginSetup ( ) ;
348
352
349
353
// Add listener
350
- plugin . on ( 'addingAnnotationDataChanged' , event => {
354
+ plugin . registerListener ( 'addingAnnotationDataChanged' , event => {
351
355
expect ( event . detail . range . start ) . to . equal ( 9 ) ;
352
356
expect ( event . detail . range . end ) . to . equal ( 20 ) ;
353
357
done ( ) ;
@@ -377,7 +381,7 @@ describe('external event-based API', () => {
377
381
const plugin = simplePluginSetup ( ) ;
378
382
379
383
// Add listener
380
- plugin . on ( 'enteredAddingAnnotation' , event => {
384
+ plugin . registerListener ( 'enteredAddingAnnotation' , event => {
381
385
expect ( event . detail . range . start ) . to . not . be . undefined ;
382
386
done ( ) ;
383
387
} ) ;
0 commit comments