Skip to content

Commit

Permalink
[Monitoring] Migrate karma tests (#75301)
Browse files Browse the repository at this point in the history
* Move to jest

* More tests
  • Loading branch information
chrisronline committed Aug 19, 2020
1 parent 53c765e commit 774c04a
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 480 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import expect from '@kbn/expect';
import { getColor } from '../get_color';
import { getColor } from './get_color';

describe('getColors', function () {
it('elasticsearch colors', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import expect from '@kbn/expect';
import { getLastValue } from '../get_last_value';
import { getLastValue } from './get_last_value';

describe('monitoringChartGetLastValue', function () {
it('getLastValue for single number', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import expect from '@kbn/expect';
import { getTitle } from '../get_title';
import { getTitle } from './get_title';

describe('getTitle', function () {
it('with metric.title', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import expect from '@kbn/expect';
import sinon from 'sinon';
import { findIndexByX, getValuesByX, getValuesForSeriesIndex } from '../get_values_for_legend';
import { findIndexByX, getValuesByX, getValuesForSeriesIndex } from './get_values_for_legend';

describe('monitoringChartHelpers', function () {
it('getValuesForSeriesIndex sets does not impact callback without series', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import expect from '@kbn/expect';
import sinon from 'sinon';
import { Config } from '../config';
import { Graph } from '../graph';
import { Config } from './config';
import { Graph } from './graph';

describe('Config class', () => {
let configJson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

import expect from '@kbn/expect';
import { BooleanEdge } from '../boolean_edge';
import { Edge } from '../edge';
import { BooleanEdge } from './boolean_edge';
import { Edge } from './edge';

describe('BooleanEdge', () => {
let graph;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import expect from '@kbn/expect';
import { Edge } from '../edge';
import { Edge } from './edge';

describe('Edge', () => {
let graph;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/

import expect from '@kbn/expect';
import { edgeFactory } from '../edge_factory';
import { Edge } from '../edge';
import { BooleanEdge } from '../boolean_edge';
import { edgeFactory } from './edge_factory';
import { Edge } from './edge';
import { BooleanEdge } from './boolean_edge';

describe('edgeFactory', () => {
let graph;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

import expect from '@kbn/expect';
import { IfVertex } from '../if_vertex';
import { Vertex } from '../vertex';
import { IfVertex } from './if_vertex';
import { Vertex } from './vertex';

describe('IfVertex', () => {
let graph;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/

import expect from '@kbn/expect';
import { Graph } from '../';
import { Vertex } from '../vertex';
import { PluginVertex } from '../plugin_vertex';
import { Edge } from '../edge';
import { Graph } from './';
import { Vertex } from './vertex';
import { PluginVertex } from './plugin_vertex';
import { Edge } from './edge';

describe('Graph', () => {
let graphJson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

import expect from '@kbn/expect';
import { Vertex } from '../vertex';
import { PluginVertex, TIME_CONSUMING_PROCESSOR_THRESHOLD_COEFFICIENT } from '../plugin_vertex';
import { Vertex } from './vertex';
import { PluginVertex, TIME_CONSUMING_PROCESSOR_THRESHOLD_COEFFICIENT } from './plugin_vertex';

describe('PluginVertex', () => {
let graph;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

import expect from '@kbn/expect';
import { QueueVertex } from '../queue_vertex';
import { Vertex } from '../vertex';
import { QueueVertex } from './queue_vertex';
import { Vertex } from './vertex';

describe('QueueVertex', () => {
let graph;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import expect from '@kbn/expect';
import { Graph } from '../';
import { Graph } from './';

describe('Vertex', () => {
let graph;
Expand Down Expand Up @@ -205,40 +205,39 @@ describe('Vertex', () => {
* \---- v
* F5
*/
const complexGraphJson = {
vertices: [
{ id: 'I1', type: 'plugin', explicit_id: false },
{ id: 'my-queue', type: 'queue', config_name: 'some-name' },
{ id: 'IF1', type: 'if', config_name: 'some-name' },
{
id: 'IF2',
type: 'plugin',
meta: { source_text: 'foobar', source_line: 33, source_column: 4 },
},
{ id: 'F1', type: 'plugin', explicit_id: true },
{ id: 'F2', type: 'plugin', explicit_id: true },
{ id: 'F3', type: 'plugin', explicit_id: true },
{ id: 'F4', type: 'plugin', explicit_id: true },
{ id: 'F5', type: 'plugin', explicit_id: true },
],
edges: [
{ id: '1', type: 'plain', from: 'I1', to: 'my-queue' },
{ id: '2', type: 'plain', from: 'my-queue', to: 'IF1' },
{ id: '3', type: 'boolean', when: true, from: 'IF1', to: 'IF2' },
{ id: '4', type: 'boolean', when: false, from: 'IF1', to: 'F1' },
{ id: '5', type: 'boolean', when: true, from: 'IF2', to: 'F2' },
{ id: '6', type: 'boolean', when: false, from: 'IF2', to: 'F3' },
{ id: '7', type: 'plain', from: 'F2', to: 'F5' },
{ id: '8', type: 'plain', from: 'F3', to: 'F5' },
{ id: '9', type: 'plain', from: 'F1', to: 'F4' },
{ id: '10', type: 'plain', from: 'F4', to: 'F5' },
],
};

beforeEach(() => {
graph = new Graph();
graph.update(complexGraphJson);
});
// const complexGraphJson = {
// vertices: [
// { id: 'I1', type: 'plugin', explicit_id: false },
// { id: 'my-queue', type: 'queue', config_name: 'some-name' },
// { id: 'IF1', type: 'if', config_name: 'some-name' },
// {
// id: 'IF2',
// type: 'plugin',
// meta: { source_text: 'foobar', source_line: 33, source_column: 4 },
// },
// { id: 'F1', type: 'plugin', explicit_id: true },
// { id: 'F2', type: 'plugin', explicit_id: true },
// { id: 'F3', type: 'plugin', explicit_id: true },
// { id: 'F4', type: 'plugin', explicit_id: true },
// { id: 'F5', type: 'plugin', explicit_id: true },
// ],
// edges: [
// { id: '1', type: 'plain', from: 'I1', to: 'my-queue' },
// { id: '2', type: 'plain', from: 'my-queue', to: 'IF1' },
// { id: '3', type: 'boolean', when: true, from: 'IF1', to: 'IF2' },
// { id: '4', type: 'boolean', when: false, from: 'IF1', to: 'F1' },
// { id: '5', type: 'boolean', when: true, from: 'IF2', to: 'F2' },
// { id: '6', type: 'boolean', when: false, from: 'IF2', to: 'F3' },
// { id: '7', type: 'plain', from: 'F2', to: 'F5' },
// { id: '8', type: 'plain', from: 'F3', to: 'F5' },
// { id: '9', type: 'plain', from: 'F1', to: 'F4' },
// { id: '10', type: 'plain', from: 'F4', to: 'F5' },
// ],
// };
// beforeEach(() => {
// graph = new Graph();
// graph.update(complexGraphJson);
// });
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/

import expect from '@kbn/expect';
import { vertexFactory } from '../vertex_factory';
import { PluginVertex } from '../plugin_vertex';
import { IfVertex } from '../if_vertex';
import { QueueVertex } from '../queue_vertex';
import { vertexFactory } from './vertex_factory';
import { PluginVertex } from './plugin_vertex';
import { IfVertex } from './if_vertex';
import { QueueVertex } from './queue_vertex';

describe('vertexFactory', () => {
let graph;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import expect from '@kbn/expect';
import sinon from 'sinon';
import { PipelineState } from '../pipeline_state';
import { Config } from '../config';
import { PipelineState } from './pipeline_state';
import { Config } from './config';

describe('PipelineState class', () => {
let configJson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,42 @@

import { noop } from 'lodash';
import expect from '@kbn/expect';
import { MonitoringMainController } from '../';
import { Legacy } from '../../legacy_shims';
import { MonitoringMainController } from './';

const getMockLicenseService = (options) => ({ mlIsSupported: () => options.mlIsSupported });
const getMockBreadcrumbsService = () => noop; // breadcrumb service has its own test

describe('Monitoring Main Directive Controller', () => {
const core = {
notifications: {},
application: {},
i18n: {},
chrome: {},
};
const data = {
query: {
timefilter: {
timefilter: {
isTimeRangeSelectorEnabled: () => true,
getTime: () => 1,
getRefreshInterval: () => 1,
},
},
},
};
const isCloud = false;
const triggersActionsUi = {};

beforeAll(() => {
Legacy.init({
core,
data,
isCloud,
triggersActionsUi,
});
});

/*
* Simulates calling the monitoringMain directive the way Cluster Listing
* does:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import expect from '@kbn/expect';
import { formatNumber, formatBytesUsage } from '../format_number';
import { formatNumber, formatBytesUsage } from './format_number';

describe('format_number', () => {
describe('formatBytesUsage', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import expect from '@kbn/expect';
import { isPipelineMonitoringSupportedInVersion } from '../pipelines';
import { isPipelineMonitoringSupportedInVersion } from './pipelines';

describe('pipelines', () => {
describe('isPipelineMonitoringSupportedInVersion', () => {
Expand Down
Loading

0 comments on commit 774c04a

Please sign in to comment.