Skip to content

Commit

Permalink
Updated Testing for get_no_items_message
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Dong <[email protected]>
  • Loading branch information
danieldong51 committed Aug 2, 2024
1 parent 1272baf commit 75e1c69
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

import { getNoItemsMessage } from './get_no_items_message';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { ApplicationStart } from 'opensearch-dashboards/public';
import { ApplicationStart, Capabilities, PublicAppInfo } from 'opensearch-dashboards/public';
import { EuiLink } from '@elastic/eui';
import { RecursiveReadonly } from '@osd/utility-types';
import { Observable } from 'rxjs';

describe('dashboard listing table with no item', () => {
test('and no write controls', () => {
Expand All @@ -15,8 +18,19 @@ describe('dashboard listing table with no item', () => {
});

test('and with write controls', () => {
const component = mountWithIntl(getNoItemsMessage(false, jest.fn(), {} as ApplicationStart));
const application = {
capabilities: {} as RecursiveReadonly<Capabilities>,
applications$: {} as Observable<ReadonlyMap<string, PublicAppInfo>>,
navigateToApp: jest.fn(),
navigateToUrl: jest.fn(),
getUrlForApp: jest.fn(),
registerMountContext: jest.fn(),
currentAppId$: {} as Observable<string | undefined>,
};
const component = mountWithIntl(getNoItemsMessage(false, jest.fn(), application));

expect(component).toMatchSnapshot();
component.find(EuiLink).simulate('click');
expect(application.navigateToApp).toHaveBeenCalledTimes(1);
});
});

0 comments on commit 75e1c69

Please sign in to comment.