1
- import Guest from '../guest' ;
1
+ import Guest , { $imports } from '../guest' ;
2
2
import { EventBus } from '../util/emitter' ;
3
- import { $imports } from '../guest' ;
4
3
5
4
class FakeAdder {
6
5
constructor ( container , options ) {
@@ -234,7 +233,7 @@ describe('Guest', () => {
234
233
} ) ;
235
234
236
235
describe ( 'events from sidebar' , ( ) => {
237
- const emitGuestEvent = ( event , ...args ) => {
236
+ const emitSidebarEvent = ( event , ...args ) => {
238
237
for ( let [ evt , fn ] of fakeBridge . on . args ) {
239
238
if ( event === evt ) {
240
239
fn ( ...args ) ;
@@ -252,7 +251,7 @@ describe('Guest', () => {
252
251
{ annotation : { $tag : 'tag2' } , highlights : [ highlight1 ] } ,
253
252
] ;
254
253
255
- emitGuestEvent ( 'focusAnnotations' , [ 'tag1' ] ) ;
254
+ emitSidebarEvent ( 'focusAnnotations' , [ 'tag1' ] ) ;
256
255
257
256
assert . calledWith (
258
257
highlighter . setHighlightsFocused ,
@@ -270,7 +269,7 @@ describe('Guest', () => {
270
269
{ annotation : { $tag : 'tag2' } , highlights : [ highlight1 ] } ,
271
270
] ;
272
271
273
- emitGuestEvent ( 'focusAnnotations' , [ 'tag1' ] ) ;
272
+ emitSidebarEvent ( 'focusAnnotations' , [ 'tag1' ] ) ;
274
273
275
274
assert . calledWith (
276
275
highlighter . setHighlightsFocused ,
@@ -282,8 +281,8 @@ describe('Guest', () => {
282
281
it ( 'updates focused tag set' , ( ) => {
283
282
const guest = createGuest ( ) ;
284
283
285
- emitGuestEvent ( 'focusAnnotations' , [ 'tag1' ] ) ;
286
- emitGuestEvent ( 'focusAnnotations' , [ 'tag2' , 'tag3' ] ) ;
284
+ emitSidebarEvent ( 'focusAnnotations' , [ 'tag1' ] ) ;
285
+ emitSidebarEvent ( 'focusAnnotations' , [ 'tag2' , 'tag3' ] ) ;
287
286
288
287
assert . deepEqual ( [ ...guest . focusedAnnotationTags ] , [ 'tag2' , 'tag3' ] ) ;
289
288
} ) ;
@@ -302,7 +301,7 @@ describe('Guest', () => {
302
301
} ,
303
302
] ;
304
303
305
- emitGuestEvent ( 'scrollToAnnotation' , 'tag1' ) ;
304
+ emitSidebarEvent ( 'scrollToAnnotation' , 'tag1' ) ;
306
305
307
306
assert . called ( fakeIntegration . scrollToAnchor ) ;
308
307
assert . calledWith ( fakeIntegration . scrollToAnchor , guest . anchors [ 0 ] ) ;
@@ -326,7 +325,7 @@ describe('Guest', () => {
326
325
resolve ( ) ;
327
326
} ) ;
328
327
329
- emitGuestEvent ( 'scrollToAnnotation' , 'tag1' ) ;
328
+ emitSidebarEvent ( 'scrollToAnnotation' , 'tag1' ) ;
330
329
} ) ;
331
330
} ) ;
332
331
@@ -345,7 +344,7 @@ describe('Guest', () => {
345
344
event . preventDefault ( )
346
345
) ;
347
346
348
- emitGuestEvent ( 'scrollToAnnotation' , 'tag1' ) ;
347
+ emitSidebarEvent ( 'scrollToAnnotation' , 'tag1' ) ;
349
348
350
349
assert . notCalled ( fakeIntegration . scrollToAnchor ) ;
351
350
} ) ;
@@ -354,7 +353,7 @@ describe('Guest', () => {
354
353
const guest = createGuest ( ) ;
355
354
356
355
guest . anchors = [ { annotation : { $tag : 'tag1' } } ] ;
357
- emitGuestEvent ( 'scrollToAnnotation' , 'tag1' ) ;
356
+ emitSidebarEvent ( 'scrollToAnnotation' , 'tag1' ) ;
358
357
359
358
assert . notCalled ( fakeIntegration . scrollToAnchor ) ;
360
359
} ) ;
@@ -374,7 +373,7 @@ describe('Guest', () => {
374
373
const eventEmitted = sandbox . stub ( ) ;
375
374
guest . element . addEventListener ( 'scrolltorange' , eventEmitted ) ;
376
375
377
- emitGuestEvent ( 'scrollToAnnotation' , 'tag1' ) ;
376
+ emitSidebarEvent ( 'scrollToAnnotation' , 'tag1' ) ;
378
377
379
378
assert . notCalled ( eventEmitted ) ;
380
379
assert . notCalled ( fakeIntegration . scrollToAnchor ) ;
@@ -408,7 +407,7 @@ describe('Guest', () => {
408
407
409
408
fakeIntegration . getMetadata . resolves ( metadata ) ;
410
409
411
- emitGuestEvent (
410
+ emitSidebarEvent (
412
411
'getDocumentInfo' ,
413
412
createCallback ( 'https://example.com/test.pdf' , metadata , done )
414
413
) ;
@@ -419,14 +418,14 @@ describe('Guest', () => {
419
418
it ( 'sets visibility of highlights in document' , ( ) => {
420
419
const guest = createGuest ( ) ;
421
420
422
- emitGuestEvent ( 'setVisibleHighlights' , true ) ;
421
+ emitSidebarEvent ( 'setVisibleHighlights' , true ) ;
423
422
assert . calledWith (
424
423
highlighter . setHighlightsVisible ,
425
424
guest . element ,
426
425
true
427
426
) ;
428
427
429
- emitGuestEvent ( 'setVisibleHighlights' , false ) ;
428
+ emitSidebarEvent ( 'setVisibleHighlights' , false ) ;
430
429
assert . calledWith (
431
430
highlighter . setHighlightsVisible ,
432
431
guest . element ,
0 commit comments