forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...lugins/apm/public/components/shared/DiscoverButtons/__test__/DiscoverErrorButton.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
...omponents/shared/DiscoverButtons/__test__/__snapshots__/DiscoverErrorButton.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
}, | ||
} | ||
} | ||
/> | ||
`; |