import { createExtract , createInject } from './dashboard_drilldown_persistable_state' ; import { SerializedEvent } from '../../../../ui_actions_enhanced/common' ; const drilldownId = 'test_id' ; const extract = createExtract ( { drilldownId } ) ; const inject = createInject ( { drilldownId } ) ; const state = { eventId : 'event_id' , triggers : [ ] , action : { factoryId : drilldownId , name : 'name' , config : { dashboardId : 'dashboardId_1' , } , } , } ; test ( 'should extract and injected dashboard reference' , ( ) => { const { state : extractedState , references } = extract ( state ) ; expect ( extractedState ) . not . toEqual ( state ) ; expect ( extractedState . action . config . dashboardId ) . toBeUndefined ( ) ; expect ( references ) . toMatchInlineSnapshot ( `
    Array [
      Object {
        "id": "dashboardId_1",
        "name": "drilldown:test_id:event_id:dashboardId",
        "type": "dashboard",
      },
    ]
  ` ) ; let injectedState = inject ( extractedState , references ) ; expect ( injectedState ) . toEqual ( state ) ; references [ 0 ] . id = 'dashboardId_2' ; injectedState = inject ( extractedState , references ) ; expect ( injectedState ) . not . toEqual ( extractedState ) ; expect ( injectedState . action . config . dashboardId ) . toBe ( 'dashboardId_2' ) ; } ) ;