Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Jan 10, 2019
1 parent f7a75fb commit 6fcc16e
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ exports[`DetailView should render StickyProperties 1`] = `
pathname="/app/apm"
query={
Object {
"traceid": "traceId",
"traceId": "traceId",
"transactionId": "myTransactionName",
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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.
*/

import { shallow, ShallowWrapper } from 'enzyme';
import 'jest-styled-components';
import React from 'react';
import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error';
import { DiscoverErrorButton } from '../DiscoverErrorButton';

describe('DiscoverErrorButton without kuery', () => {
let wrapper: ShallowWrapper;
beforeEach(() => {
const error = {
context: { service: { name: 'myServiceName' } },
error: { grouping_key: 'myGroupingKey' }
} as APMError;

wrapper = shallow(<DiscoverErrorButton error={error} />);
});

it('should have correct query', () => {
const queryProp = wrapper.prop('query') as any;
expect(queryProp._a.query.query).toEqual(
'context.service.name:"myServiceName" AND error.grouping_key:"myGroupingKey"'
);
});

it('should match snapshot', () => {
expect(wrapper).toMatchSnapshot();
});
});

describe('DiscoverErrorButton with kuery', () => {
let wrapper: ShallowWrapper;
beforeEach(() => {
const error = {
context: { service: { name: 'myServiceName' } },
error: { grouping_key: 'myGroupingKey' }
} as APMError;

const kuery = 'transaction.sampled: true';

wrapper = shallow(<DiscoverErrorButton error={error} kuery={kuery} />);
});

it('should have correct query', () => {
const queryProp = wrapper.prop('query') as any;
expect(queryProp._a.query.query).toEqual(
'context.service.name:"myServiceName" AND error.grouping_key:"myGroupingKey" AND transaction.sampled: true'
);
});

it('should match snapshot', () => {
expect(wrapper).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DiscoverErrorButton with kuery should match snapshot 1`] = `
<DiscoverButton
query={
Object {
"_a": Object {
"interval": "auto",
"query": Object {
"language": "lucene",
"query": "context.service.name:\\"myServiceName\\" AND error.grouping_key:\\"myGroupingKey\\" AND transaction.sampled: true",
},
"sort": Object {
"@timestamp": "desc",
},
},
}
}
/>
`;

exports[`DiscoverErrorButton without kuery should match snapshot 1`] = `
<DiscoverButton
query={
Object {
"_a": Object {
"interval": "auto",
"query": Object {
"language": "lucene",
"query": "context.service.name:\\"myServiceName\\" AND error.grouping_key:\\"myGroupingKey\\"",
},
"sort": Object {
"@timestamp": "desc",
},
},
}
}
/>
`;

0 comments on commit 6fcc16e

Please sign in to comment.