Skip to content

Commit

Permalink
chore(NA): move grokdebugger plugin test fixtures out of __tests__ fo…
Browse files Browse the repository at this point in the history
…lder (#87765) (#87774)
  • Loading branch information
mistic authored Jan 8, 2021
1 parent aa1412d commit 1a5eae3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
11 changes: 11 additions & 0 deletions x-pack/plugins/grokdebugger/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/x-pack/plugins/grokdebugger'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { GrokdebuggerRequest } from '../grokdebugger_request';
import { GrokdebuggerRequest } from './grokdebugger_request';

// FAILING: https://github.com/elastic/kibana/issues/51372
describe.skip('grokdebugger_request', () => {
Expand All @@ -24,18 +23,18 @@ describe.skip('grokdebugger_request', () => {
describe('fromDownstreamJSON factory method', () => {
it('returns correct GrokdebuggerRequest instance from downstreamRequest', () => {
const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(downstreamRequest);
expect(grokdebuggerRequest.rawEvent).to.eql(downstreamRequest.rawEvent);
expect(grokdebuggerRequest.pattern).to.eql(downstreamRequest.pattern);
expect(grokdebuggerRequest.customPatterns).to.eql({});
expect(grokdebuggerRequest.rawEvent).toEqual(downstreamRequest.rawEvent);
expect(grokdebuggerRequest.pattern).toEqual(downstreamRequest.pattern);
expect(grokdebuggerRequest.customPatterns).toEqual({});
});

it('returns correct GrokdebuggerRequest instance from downstreamRequest when custom patterns are specified', () => {
const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(
downstreamRequestWithCustomPatterns
);
expect(grokdebuggerRequest.rawEvent).to.eql(downstreamRequest.rawEvent);
expect(grokdebuggerRequest.pattern).to.eql(downstreamRequest.pattern);
expect(grokdebuggerRequest.customPatterns).to.eql('%{FOO:bar}');
expect(grokdebuggerRequest.rawEvent).toEqual(downstreamRequest.rawEvent);
expect(grokdebuggerRequest.pattern).toEqual(downstreamRequest.pattern);
expect(grokdebuggerRequest.customPatterns).toEqual('%{FOO:bar}');
});
});

Expand Down Expand Up @@ -67,7 +66,7 @@ describe.skip('grokdebugger_request', () => {
};
const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(downstreamRequest);
const upstreamJson = grokdebuggerRequest.upstreamJSON;
expect(upstreamJson).to.eql(expectedUpstreamJSON);
expect(upstreamJson).toEqual(expectedUpstreamJSON);
});

it('returns the upstream simulate JSON request when custom patterns are specified', () => {
Expand Down Expand Up @@ -99,7 +98,7 @@ describe.skip('grokdebugger_request', () => {
downstreamRequestWithCustomPatterns
);
const upstreamJson = grokdebuggerRequest.upstreamJSON;
expect(upstreamJson).to.eql(expectedUpstreamJSON);
expect(upstreamJson).toEqual(expectedUpstreamJSON);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { GrokdebuggerResponse } from '../grokdebugger_response';
import { GrokdebuggerResponse } from './grokdebugger_response';

describe('grokdebugger_response', () => {
describe('GrokdebuggerResponse', () => {
Expand Down Expand Up @@ -38,8 +37,8 @@ describe('grokdebugger_response', () => {
client: '55.3.244.1',
};
const grokdebuggerResponse = GrokdebuggerResponse.fromUpstreamJSON(upstreamJson);
expect(grokdebuggerResponse.structuredEvent).to.eql(expectedStructuredEvent);
expect(grokdebuggerResponse.error).to.eql({});
expect(grokdebuggerResponse.structuredEvent).toEqual(expectedStructuredEvent);
expect(grokdebuggerResponse.error).toEqual({});
});

it('returns correct GrokdebuggerResponse instance when there are valid grok parse errors', () => {
Expand All @@ -62,8 +61,8 @@ describe('grokdebugger_response', () => {
],
};
const grokdebuggerResponse = GrokdebuggerResponse.fromUpstreamJSON(upstreamJson);
expect(grokdebuggerResponse.structuredEvent).to.eql({});
expect(grokdebuggerResponse.error).to.be(
expect(grokdebuggerResponse.structuredEvent).toEqual({});
expect(grokdebuggerResponse.error).toBe(
'Provided Grok patterns do not match data in the input'
);
});
Expand Down

0 comments on commit 1a5eae3

Please sign in to comment.