Skip to content

Commit 59871e5

Browse files
committed
Added jest tests
1 parent b5106b4 commit 59871e5

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import { coreMock, scopedHistoryMock } from '../../../../../core/public/mocks';
2121
import { EmbeddableStateTransfer } from '.';
22-
import { ApplicationStart } from '../../../../../core/public';
22+
import { ApplicationStart, PublicAppInfo } from '../../../../../core/public';
2323

2424
function 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

Comments
 (0)