Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Jan 5, 2024
1 parent b125ca6 commit dfde301
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 330 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ jest.mock('./utils', () => ({
getCustomChartData: jest.fn().mockReturnValue(true),
}));

const mockUseVisualizationResponse = jest.fn(() => [
{ aggregations: [{ buckets: [{ key: '1234' }] }], hits: { total: 999 } },
]);
const mockUseVisualizationResponse = jest.fn(() => ({
responses: [{ aggregations: [{ buckets: [{ key: '1234' }] }], hits: { total: 999 } }],
}));
jest.mock('../visualization_actions/use_visualization_response', () => ({
useVisualizationResponse: () => mockUseVisualizationResponse(),
}));
Expand Down Expand Up @@ -345,9 +345,9 @@ describe('Matrix Histogram Component', () => {
});

test('it should render 0 as subtitle when buckets are empty', () => {
mockUseVisualizationResponse.mockReturnValue([
{ aggregations: [{ buckets: [] }], hits: { total: 999 } },
]);
mockUseVisualizationResponse.mockReturnValue({
responses: [{ aggregations: [{ buckets: [] }], hits: { total: 999 } }],
});
mockUseMatrix.mockReturnValue([
false,
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
export const VISUALIZATION_CONTEXT_MENU_TRIGGER = 'VISUALIZATION_CONTEXT_MENU_TRIGGER';
export const DEFAULT_ACTIONS = [
'inspect',
'addToNewCase',
'addToExistingCase',
'saveToLibrary',
'openInLens',
];
export const MOCK_ACTIONS = [
{
id: 'inspect',
getDisplayName: () => 'Inspect',
getIconType: () => 'inspect',
type: 'actionButton',
order: 4,
isCompatible: () => true,
execute: jest.fn(),
},
{
id: 'addToNewCase',
getDisplayName: () => 'Add to new case',
getIconType: () => 'casesApp',
type: 'actionButton',
order: 3,
isCompatible: () => true,
execute: jest.fn(),
},
{
id: 'addToExistingCase',
getDisplayName: () => 'Add to existing case',
getIconType: () => 'casesApp',
type: 'actionButton',
order: 2,
isCompatible: () => true,
execute: jest.fn(),
},
{
id: 'saveToLibrary',
getDisplayName: () => 'Added to library',
getIconType: () => 'save',
type: 'actionButton',
order: 1,
isCompatible: () => true,
execute: jest.fn(),
},
{
id: 'openInLens',
getDisplayName: () => 'Open in Lens',
getIconType: () => 'visArea',
type: 'actionButton',
order: 0,
isCompatible: () => true,
execute: jest.fn(),
},
];
export const useActions = jest.fn().mockReturnValue(MOCK_ACTIONS);
Loading

0 comments on commit dfde301

Please sign in to comment.