1919
2020import { coreMock , scopedHistoryMock } from '../../../../../core/public/mocks' ;
2121import { EmbeddableStateTransfer } from '.' ;
22- import { ApplicationStart } from '../../../../../core/public' ;
22+ import { ApplicationStart , PublicAppInfo } from '../../../../../core/public' ;
2323
2424function mockHistoryState ( state : unknown ) {
2525 return scopedHistoryMock . create ( { state } ) ;
@@ -37,6 +37,29 @@ describe('embeddable state transfer', () => {
3737 stateTransfer = new EmbeddableStateTransfer ( application . navigateToApp ) ;
3838 } ) ;
3939
40+ it ( 'cannot fetch app name when given no app list' , async ( ) => {
41+ expect ( stateTransfer . getAppNameFromId ( 'test' ) ) . toBeUndefined ( ) ;
42+ } ) ;
43+
44+ it ( 'cannot fetch app name when app id is not in given app list' , async ( ) => {
45+ const appsList = new Map < string , PublicAppInfo > ( [
46+ [ 'testId' , { title : 'State Transfer Test App Hello' } as PublicAppInfo ] ,
47+ [ 'testId2' , { title : 'State Transfer Test App Goodbye' } as PublicAppInfo ] ,
48+ ] ) ;
49+ stateTransfer = new EmbeddableStateTransfer ( application . navigateToApp , undefined , appsList ) ;
50+ expect ( stateTransfer . getAppNameFromId ( 'kibanana' ) ) . toBeUndefined ( ) ;
51+ } ) ;
52+
53+ it ( 'can fetch app titles when given app list' , async ( ) => {
54+ const appsList = new Map < string , PublicAppInfo > ( [
55+ [ 'testId' , { title : 'State Transfer Test App Hello' } as PublicAppInfo ] ,
56+ [ 'testId2' , { title : 'State Transfer Test App Goodbye' } as PublicAppInfo ] ,
57+ ] ) ;
58+ stateTransfer = new EmbeddableStateTransfer ( application . navigateToApp , undefined , appsList ) ;
59+ expect ( stateTransfer . getAppNameFromId ( 'testId' ) ) . toBe ( 'State Transfer Test App Hello' ) ;
60+ expect ( stateTransfer . getAppNameFromId ( 'testId2' ) ) . toBe ( 'State Transfer Test App Goodbye' ) ;
61+ } ) ;
62+
4063 it ( 'can send an outgoing originating app state' , async ( ) => {
4164 await stateTransfer . navigateToEditor ( destinationApp , { state : { originatingApp } } ) ;
4265 expect ( application . navigateToApp ) . toHaveBeenCalledWith ( 'superUltraVisualize' , {
0 commit comments