import mockAnnotations from '../components/annotations/annotations_table/__mocks__/mock_annotations.json' ; import { Annotation } from '../../../common/types/annotations' ; import { annotationsRefresh$ , annotationsRefreshed , AnnotationUpdatesService , } from './annotations_service' ; describe ( 'annotations_service' , ( ) => { let annotationUpdatesService = null ; beforeEach ( ( ) => { annotationUpdatesService = new AnnotationUpdatesService ( ) ; } ) ; test ( 'annotationUpdatesService' , ( ) => { const subscriber = jest . fn ( ) ; annotationUpdatesService ! . update$ ( ) . subscribe ( subscriber ) ; expect ( subscriber . mock . calls ) . toHaveLength ( 1 ) ; expect ( subscriber . mock . calls [ 0 ] [ 0 ] ) . toBe ( null ) ; const annotation = mockAnnotations [ 0 ] as Annotation ; annotationUpdatesService ! . setValue ( annotation ) ; expect ( subscriber . mock . calls ) . toHaveLength ( 2 ) ; expect ( subscriber . mock . calls [ 1 ] [ 0 ] ) . toEqual ( annotation ) ; } ) ; test ( 'annotationsRefresh$' , ( ) => { const subscriber = jest . fn ( ) ; annotationsRefresh$ . subscribe ( subscriber ) ; expect ( subscriber . mock . calls ) . toHaveLength ( 1 ) ; annotationsRefreshed ( ) ; expect ( subscriber . mock . calls ) . toHaveLength ( 2 ) ; } ) ; } ) ;