-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Joseph McElroy <joseph.mcelroy@elastic.co>
- Loading branch information
1 parent
c423cc5
commit 267e098
Showing
14 changed files
with
179 additions
and
20 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...w/components/elasticsearch_client_instructions/elasticsearch_client_instructions.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,57 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { setMockValues } from '../../../__mocks__/kea_logic'; | ||
|
||
import React from 'react'; | ||
|
||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
|
||
import * as Languages from './languages'; | ||
|
||
import { ElasticsearchClientInstructions } from '.'; | ||
|
||
describe('Elasticsearch Client Instructions', () => { | ||
let wrapper: ShallowWrapper; | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
const setup = (language: string) => { | ||
setMockValues({ | ||
cloud: { | ||
cloudId: 'example-cloud-id', | ||
}, | ||
}); | ||
wrapper = shallow(<ElasticsearchClientInstructions language={language} />); | ||
}; | ||
|
||
describe('Displaying the right language options', () => { | ||
it.concurrent.each([ | ||
['dotnet', Languages.ElasticsearchDotnet, false], | ||
['go', Languages.ElasticsearchGo, true], | ||
['java', Languages.ElasticsearchJava, false], | ||
['javascript', Languages.ElasticsearchJavascript, true], | ||
['php', Languages.ElasticsearchPhp, true], | ||
['python', Languages.ElasticsearchPython, true], | ||
['ruby', Languages.ElasticsearchRuby, true], | ||
['rust', Languages.ElasticsearchRust, false], | ||
])('%s', (language, Component, hasCloudIdProp) => { | ||
setup(language); | ||
expect(wrapper.find(Component)).toHaveLength(1); | ||
expect(wrapper.find(Component).prop('cloudId')).toEqual( | ||
hasCloudIdProp ? 'example-cloud-id' : undefined | ||
); | ||
}); | ||
}); | ||
|
||
it('does not display language for unrecognised language', () => { | ||
setup('coffeescript'); | ||
expect(wrapper.isEmptyRender()).toEqual(true); | ||
}); | ||
}); |
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
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
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
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
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
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
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
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
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
26 changes: 26 additions & 0 deletions
26
...nterprise_search_overview/components/elasticsearch_client_instructions/languages/index.ts
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,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { ElasticsearchDotnet } from './elasticsearch_dotnet'; | ||
import { ElasticsearchGo } from './elasticsearch_go'; | ||
import { ElasticsearchJava } from './elasticsearch_java'; | ||
import { ElasticsearchJavascript } from './elasticsearch_javascript'; | ||
import { ElasticsearchPhp } from './elasticsearch_php'; | ||
import { ElasticsearchPython } from './elasticsearch_python'; | ||
import { ElasticsearchRuby } from './elasticsearch_ruby'; | ||
import { ElasticsearchRust } from './elasticsearch_rust'; | ||
|
||
export { | ||
ElasticsearchDotnet, | ||
ElasticsearchGo, | ||
ElasticsearchJava, | ||
ElasticsearchJavascript, | ||
ElasticsearchPhp, | ||
ElasticsearchPython, | ||
ElasticsearchRuby, | ||
ElasticsearchRust, | ||
}; |
73 changes: 73 additions & 0 deletions
73
...ns/enterprise_search_overview/components/elasticsearch_guide/elasticsearch_guide.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,73 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
|
||
import { EuiSteps, EuiSelect } from '@elastic/eui'; | ||
|
||
import { ElasticsearchClientInstructions } from '../elasticsearch_client_instructions'; | ||
|
||
import { ElasticsearchGuide } from './'; | ||
|
||
describe('Elasticsearch Guide Component', () => { | ||
let wrapper: ShallowWrapper; | ||
|
||
const setup = (param: string) => { | ||
Object.defineProperty(window, 'location', { | ||
value: { search: param }, | ||
writable: true, | ||
}); | ||
wrapper = shallow(<ElasticsearchGuide />); | ||
}; | ||
|
||
describe('Rendering Language option ', () => { | ||
it('should use default language (java)', () => { | ||
setup(''); | ||
const clientInstructionsElement = wrapper | ||
.find(EuiSteps) | ||
.dive() | ||
.find(ElasticsearchClientInstructions); | ||
expect(clientInstructionsElement.prop('language')).toBe('java'); | ||
}); | ||
|
||
it('should use language from param (ruby)', () => { | ||
setup('?client=ruby'); | ||
const clientInstructionsElement = wrapper | ||
.find(EuiSteps) | ||
.dive() | ||
.find(ElasticsearchClientInstructions); | ||
expect(clientInstructionsElement.prop('language')).toBe('ruby'); | ||
}); | ||
|
||
it('should fallback to java if client not recognised', () => { | ||
setup('?client=coffeescript'); | ||
const clientInstructionsElement = wrapper | ||
.find(EuiSteps) | ||
.dive() | ||
.find(ElasticsearchClientInstructions); | ||
expect(clientInstructionsElement.prop('language')).toBe('java'); | ||
}); | ||
}); | ||
|
||
describe('Changing Language option', () => { | ||
it('should change the client instructions language prop when choosing another option', () => { | ||
setup(''); | ||
const languageSelectElement = wrapper.find(EuiSteps).dive().find(EuiSelect); | ||
languageSelectElement.simulate('change', { target: { value: 'ruby' } }); | ||
|
||
wrapper.update(); | ||
|
||
const clientInstructionsElement = wrapper | ||
.find(EuiSteps) | ||
.dive() | ||
.find(ElasticsearchClientInstructions); | ||
expect(clientInstructionsElement.prop('language')).toBe('ruby'); | ||
}); | ||
}); | ||
}); |
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
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