Skip to content

Commit dd71d8f

Browse files
authored
[7.x] chore(NA): move monitoring out of __tests__ folder (#87556) (#87689)
* chore(NA): move monitoring out of __tests__ folder (#87556) * chore(NA): move server and common from monitoring out of the __tests__ folder * chore(NA): move monitoring public out of __tests__ folder * chore(NA): add missing skip on test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # x-pack/plugins/monitoring/server/kibana_monitoring/collectors/get_default_admin_email.test.js * test(NA): fix tests * chore(NA): fix some tests
1 parent ebf3dae commit dd71d8f

File tree

119 files changed

+1069
-1126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1069
-1126
lines changed

x-pack/plugins/monitoring/common/__tests__/format_timestamp_to_duration.js renamed to x-pack/plugins/monitoring/common/format_timestamp_to_duration.test.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import expect from '@kbn/expect';
87
import moment from 'moment';
9-
import { formatTimestampToDuration } from '../format_timestamp_to_duration';
10-
import { CALCULATE_DURATION_SINCE, CALCULATE_DURATION_UNTIL } from '../constants';
8+
import { formatTimestampToDuration } from './format_timestamp_to_duration';
9+
import { CALCULATE_DURATION_SINCE, CALCULATE_DURATION_UNTIL } from './constants';
1110

1211
const testTime = moment('2010-05-01'); // pick a date where adding/subtracting 2 months formats roundly to '2 months 0 days'
1312
const getTestTime = () => moment(testTime); // clones the obj so it's not mutated with .adds and .subtracts
@@ -22,23 +21,23 @@ describe('formatTimestampToDuration', () => {
2221
const fiftyNineSeconds = getTestTime().subtract(59, 'seconds');
2322
expect(
2423
formatTimestampToDuration(fiftyNineSeconds, CALCULATE_DURATION_SINCE, getTestTime())
25-
).to.be('59 seconds');
24+
).toBe('59 seconds');
2625

2726
const fiveMins = getTestTime().subtract(5, 'minutes').subtract(30, 'seconds');
28-
expect(formatTimestampToDuration(fiveMins, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
27+
expect(formatTimestampToDuration(fiveMins, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
2928
'6 mins'
3029
);
3130

3231
const sixHours = getTestTime().subtract(6, 'hours').subtract(30, 'minutes');
33-
expect(formatTimestampToDuration(sixHours, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
32+
expect(formatTimestampToDuration(sixHours, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
3433
'6 hrs 30 mins'
3534
);
3635

3736
const sevenDays = getTestTime()
3837
.subtract(7, 'days')
3938
.subtract(6, 'hours')
4039
.subtract(18, 'minutes');
41-
expect(formatTimestampToDuration(sevenDays, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
40+
expect(formatTimestampToDuration(sevenDays, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
4241
'7 days 6 hrs 18 mins'
4342
);
4443

@@ -47,22 +46,22 @@ describe('formatTimestampToDuration', () => {
4746
.subtract(7, 'days')
4847
.subtract(6, 'hours')
4948
.subtract(18, 'minutes');
50-
expect(formatTimestampToDuration(eightWeeks, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
49+
expect(formatTimestampToDuration(eightWeeks, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
5150
'2 months 2 days'
5251
);
5352

5453
const oneHour = getTestTime().subtract(1, 'hour'); // should trim 0 min
55-
expect(formatTimestampToDuration(oneHour, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
54+
expect(formatTimestampToDuration(oneHour, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
5655
'1 hr'
5756
);
5857

5958
const oneDay = getTestTime().subtract(1, 'day'); // should trim 0 hrs
60-
expect(formatTimestampToDuration(oneDay, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
59+
expect(formatTimestampToDuration(oneDay, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
6160
'1 day'
6261
);
6362

6463
const twoMonths = getTestTime().subtract(2, 'month'); // should trim 0 days
65-
expect(formatTimestampToDuration(twoMonths, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
64+
expect(formatTimestampToDuration(twoMonths, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
6665
'2 months'
6766
);
6867
});
@@ -74,20 +73,20 @@ describe('formatTimestampToDuration', () => {
7473
const fiftyNineSeconds = getTestTime().add(59, 'seconds');
7574
expect(
7675
formatTimestampToDuration(fiftyNineSeconds, CALCULATE_DURATION_UNTIL, getTestTime())
77-
).to.be('59 seconds');
76+
).toBe('59 seconds');
7877

7978
const fiveMins = getTestTime().add(10, 'minutes');
80-
expect(formatTimestampToDuration(fiveMins, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
79+
expect(formatTimestampToDuration(fiveMins, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
8180
'10 mins'
8281
);
8382

8483
const sixHours = getTestTime().add(6, 'hours').add(30, 'minutes');
85-
expect(formatTimestampToDuration(sixHours, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
84+
expect(formatTimestampToDuration(sixHours, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
8685
'6 hrs 30 mins'
8786
);
8887

8988
const sevenDays = getTestTime().add(7, 'days').add(6, 'hours').add(18, 'minutes');
90-
expect(formatTimestampToDuration(sevenDays, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
89+
expect(formatTimestampToDuration(sevenDays, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
9190
'7 days 6 hrs 18 mins'
9291
);
9392

@@ -96,22 +95,22 @@ describe('formatTimestampToDuration', () => {
9695
.add(7, 'days')
9796
.add(6, 'hours')
9897
.add(18, 'minutes');
99-
expect(formatTimestampToDuration(eightWeeks, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
98+
expect(formatTimestampToDuration(eightWeeks, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
10099
'2 months 2 days'
101100
);
102101

103102
const oneHour = getTestTime().add(1, 'hour'); // should trim 0 min
104-
expect(formatTimestampToDuration(oneHour, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
103+
expect(formatTimestampToDuration(oneHour, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
105104
'1 hr'
106105
);
107106

108107
const oneDay = getTestTime().add(1, 'day'); // should trim 0 hrs
109-
expect(formatTimestampToDuration(oneDay, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
108+
expect(formatTimestampToDuration(oneDay, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
110109
'1 day'
111110
);
112111

113112
const twoMonths = getTestTime().add(2, 'month'); // should trim 0 days
114-
expect(formatTimestampToDuration(twoMonths, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
113+
expect(formatTimestampToDuration(twoMonths, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
115114
'2 months'
116115
);
117116
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import React from 'react';
88
import { renderWithIntl } from '@kbn/test/jest';
9-
import { BytesUsage, BytesPercentageUsage } from '../helpers';
9+
import { BytesUsage, BytesPercentageUsage } from './helpers';
1010

1111
describe('Bytes Usage', () => {
1212
it('should format correctly with used and max bytes', () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import React from 'react';
88
import { renderWithIntl } from '@kbn/test/jest';
9-
import { MetricCell } from '../cells';
9+
import { MetricCell } from './cells';
1010

1111
describe('Node Listing Metric Cell', () => {
1212
it('should format a percentage metric', () => {
Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import expect from '@kbn/expect';
8-
import { IfStatement } from '../if_statement';
9-
import { PluginVertex } from '../../graph/plugin_vertex';
10-
import { IfElement } from '../../list/if_element';
11-
import { PluginElement } from '../../list/plugin_element';
7+
import { IfStatement } from './if_statement';
8+
import { PluginVertex } from '../graph/plugin_vertex';
9+
import { IfElement } from '../list/if_element';
10+
import { PluginElement } from '../list/plugin_element';
1211

1312
describe('IfStatement class', () => {
1413
let ifVertex;
@@ -57,16 +56,16 @@ describe('IfStatement class', () => {
5756
it('creates a IfStatement from vertex props', () => {
5857
const ifStatement = IfStatement.fromPipelineGraphVertex(ifVertex, pipelineStage);
5958

60-
expect(ifStatement.id).to.be('0aef421');
61-
expect(ifStatement.hasExplicitId).to.be(false);
62-
expect(ifStatement.stats).to.eql({});
63-
expect(ifStatement.meta).to.be(meta);
64-
expect(ifStatement.condition).to.be('[is_rt] == "RT"');
65-
expect(ifStatement.trueStatements).to.be.an(Array);
66-
expect(ifStatement.trueStatements.length).to.be(1);
67-
expect(ifStatement.elseStatements).to.be.an(Array);
68-
expect(ifStatement.elseStatements.length).to.be(0);
69-
expect(ifStatement.vertex).to.eql(ifVertex);
59+
expect(ifStatement.id).toBe('0aef421');
60+
expect(ifStatement.hasExplicitId).toBe(false);
61+
expect(ifStatement.stats).toEqual({});
62+
expect(ifStatement.meta).toBe(meta);
63+
expect(ifStatement.condition).toBe('[is_rt] == "RT"');
64+
expect(ifStatement.trueStatements).toBeInstanceOf(Array);
65+
expect(ifStatement.trueStatements.length).toBe(1);
66+
expect(ifStatement.elseStatements).toBeInstanceOf(Array);
67+
expect(ifStatement.elseStatements.length).toBe(0);
68+
expect(ifStatement.vertex).toEqual(ifVertex);
7069
});
7170
});
7271

@@ -99,16 +98,16 @@ describe('IfStatement class', () => {
9998
it('creates a IfStatement from vertex props', () => {
10099
const ifStatement = IfStatement.fromPipelineGraphVertex(ifVertex, pipelineStage);
101100

102-
expect(ifStatement.id).to.be('0aef421');
103-
expect(ifStatement.hasExplicitId).to.be(false);
104-
expect(ifStatement.stats).to.eql({});
105-
expect(ifStatement.meta).to.be(meta);
106-
expect(ifStatement.condition).to.be('[is_rt] == "RT"');
107-
expect(ifStatement.trueStatements).to.be.an(Array);
108-
expect(ifStatement.trueStatements.length).to.be(1);
109-
expect(ifStatement.elseStatements).to.be.an(Array);
110-
expect(ifStatement.elseStatements.length).to.be(1);
111-
expect(ifStatement.vertex).to.eql(ifVertex);
101+
expect(ifStatement.id).toBe('0aef421');
102+
expect(ifStatement.hasExplicitId).toBe(false);
103+
expect(ifStatement.stats).toEqual({});
104+
expect(ifStatement.meta).toBe(meta);
105+
expect(ifStatement.condition).toBe('[is_rt] == "RT"');
106+
expect(ifStatement.trueStatements).toBeInstanceOf(Array);
107+
expect(ifStatement.trueStatements.length).toBe(1);
108+
expect(ifStatement.elseStatements).toBeInstanceOf(Array);
109+
expect(ifStatement.elseStatements.length).toBe(1);
110+
expect(ifStatement.vertex).toEqual(ifVertex);
112111
});
113112
});
114113

@@ -142,16 +141,16 @@ describe('IfStatement class', () => {
142141
it('creates a IfStatement from vertex props', () => {
143142
const ifStatement = IfStatement.fromPipelineGraphVertex(ifVertex, pipelineStage);
144143

145-
expect(ifStatement.id).to.be('0aef421');
146-
expect(ifStatement.hasExplicitId).to.be(false);
147-
expect(ifStatement.stats).to.eql({});
148-
expect(ifStatement.meta).to.be(meta);
149-
expect(ifStatement.condition).to.be('[is_rt] == "RT"');
150-
expect(ifStatement.trueStatements).to.be.an(Array);
151-
expect(ifStatement.trueStatements.length).to.be(2);
152-
expect(ifStatement.elseStatements).to.be.an(Array);
153-
expect(ifStatement.elseStatements.length).to.be(0);
154-
expect(ifStatement.vertex).to.eql(ifVertex);
144+
expect(ifStatement.id).toBe('0aef421');
145+
expect(ifStatement.hasExplicitId).toBe(false);
146+
expect(ifStatement.stats).toEqual({});
147+
expect(ifStatement.meta).toBe(meta);
148+
expect(ifStatement.condition).toBe('[is_rt] == "RT"');
149+
expect(ifStatement.trueStatements).toBeInstanceOf(Array);
150+
expect(ifStatement.trueStatements.length).toBe(2);
151+
expect(ifStatement.elseStatements).toBeInstanceOf(Array);
152+
expect(ifStatement.elseStatements.length).toBe(0);
153+
expect(ifStatement.vertex).toEqual(ifVertex);
155154
});
156155
});
157156

@@ -193,16 +192,16 @@ describe('IfStatement class', () => {
193192
it('creates a IfStatement from vertex props', () => {
194193
const ifStatement = IfStatement.fromPipelineGraphVertex(ifVertex, pipelineStage);
195194

196-
expect(ifStatement.id).to.be('0aef421');
197-
expect(ifStatement.hasExplicitId).to.be(false);
198-
expect(ifStatement.stats).to.eql({});
199-
expect(ifStatement.meta).to.be(meta);
200-
expect(ifStatement.condition).to.be('[is_rt] == "RT"');
201-
expect(ifStatement.trueStatements).to.be.an(Array);
202-
expect(ifStatement.trueStatements.length).to.be(1);
203-
expect(ifStatement.elseStatements).to.be.an(Array);
204-
expect(ifStatement.elseStatements.length).to.be(2);
205-
expect(ifStatement.vertex).to.eql(ifVertex);
195+
expect(ifStatement.id).toBe('0aef421');
196+
expect(ifStatement.hasExplicitId).toBe(false);
197+
expect(ifStatement.stats).toEqual({});
198+
expect(ifStatement.meta).toBe(meta);
199+
expect(ifStatement.condition).toBe('[is_rt] == "RT"');
200+
expect(ifStatement.trueStatements).toBeInstanceOf(Array);
201+
expect(ifStatement.trueStatements.length).toBe(1);
202+
expect(ifStatement.elseStatements).toBeInstanceOf(Array);
203+
expect(ifStatement.elseStatements.length).toBe(2);
204+
expect(ifStatement.vertex).toEqual(ifVertex);
206205
});
207206
});
208207

@@ -220,14 +219,14 @@ describe('IfStatement class', () => {
220219

221220
const result = ifStatement.toList(0, 'output');
222221

223-
expect(result).to.be.an(Array);
224-
expect(result.length).to.be(2);
225-
expect(result[0]).to.be.an(IfElement);
226-
expect(result[0].id).to.be('0aef421');
227-
expect(result[1]).to.be.an(PluginElement);
222+
expect(result).toBeInstanceOf(Array);
223+
expect(result.length).toBe(2);
224+
expect(result[0]).toBeInstanceOf(IfElement);
225+
expect(result[0].id).toBe('0aef421');
226+
expect(result[1]).toBeInstanceOf(PluginElement);
228227
const plugin = result[1];
229-
expect(plugin).to.be.an(PluginElement);
230-
expect(plugin.id).to.be('es_output');
228+
expect(plugin).toBeInstanceOf(PluginElement);
229+
expect(plugin.id).toBe('es_output');
231230
});
232231
});
233232
});
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,19 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import expect from '@kbn/expect';
8-
import { makeStatement } from '../make_statement';
9-
import { PluginVertex } from '../../graph/plugin_vertex';
10-
import { IfVertex } from '../../graph/if_vertex';
11-
import { QueueVertex } from '../../graph/queue_vertex';
12-
import { PluginStatement } from '../plugin_statement';
13-
import { IfStatement } from '../if_statement';
14-
import { Queue } from '../queue';
7+
import { makeStatement } from './make_statement';
8+
import { PluginVertex } from '../graph/plugin_vertex';
9+
import { IfVertex } from '../graph/if_vertex';
10+
import { QueueVertex } from '../graph/queue_vertex';
11+
import { PluginStatement } from './plugin_statement';
12+
import { IfStatement } from './if_statement';
13+
import { Queue } from './queue';
1514

1615
describe('makeStatement', () => {
1716
it('can make a PluginStatement from a PluginVertex', () => {
1817
const pluginVertex = new PluginVertex({}, { json: { id: 'my_grok' } });
1918
const actual = makeStatement(pluginVertex, 'output');
20-
expect(actual).to.be.a(PluginStatement);
19+
expect(actual).toBeInstanceOf(PluginStatement);
2120
});
2221

2322
it('can make an IfStatement from an IfVertex', () => {
@@ -37,17 +36,19 @@ describe('makeStatement', () => {
3736
{ json: { id: 'abcdef0' } }
3837
);
3938
const actual = makeStatement(ifVertex, 'output');
40-
expect(actual).to.be.a(IfStatement);
39+
expect(actual).toBeInstanceOf(IfStatement);
4140
});
4241

4342
it('can make a Queue from a QueueVertex', () => {
4443
const queueVertex = new QueueVertex({}, { json: { id: '__QUEUE__' } });
4544
const actual = makeStatement(queueVertex);
46-
expect(actual).to.be.a(Queue);
45+
expect(actual).toBeInstanceOf(Queue);
4746
});
4847

4948
it('throws an error for an unknown type of vertex', () => {
5049
const unknownVertex = {};
51-
expect(makeStatement).withArgs(unknownVertex, 'output').to.throwError();
50+
expect(() => {
51+
makeStatement(unknownVertex, 'output');
52+
}).toThrow();
5253
});
5354
});

0 commit comments

Comments
 (0)