-
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.
- Loading branch information
1 parent
6199b38
commit b74921a
Showing
23 changed files
with
1,334 additions
and
199 deletions.
There are no files selected for viewing
213 changes: 213 additions & 0 deletions
213
...ard/components/step_index_pattern/__tests__/__snapshots__/step_index_pattern.test.js.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,213 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`StepIndexPattern should render normally 1`] = ` | ||
<EuiPanel | ||
grow={true} | ||
hasShadow={false} | ||
paddingSize="l" | ||
> | ||
<Header | ||
characterList="\\\\, /, ?, \\", <, >, |" | ||
errors={Array []} | ||
goToNextStep={[Function]} | ||
isInputInvalid={false} | ||
isNextStepDisabled={true} | ||
onQueryChanged={[Function]} | ||
query="k" | ||
/> | ||
<EuiSpacer | ||
size="s" | ||
/> | ||
<StatusMessage | ||
matchedIndices={ | ||
Object { | ||
"allIndices": Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
Object { | ||
"name": "es", | ||
}, | ||
], | ||
"exactMatchedIndices": Array [], | ||
"partialMatchedIndices": Array [], | ||
"visibleIndices": Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
Object { | ||
"name": "es", | ||
}, | ||
], | ||
} | ||
} | ||
query="k" | ||
/> | ||
<EuiSpacer | ||
size="s" | ||
/> | ||
<IndicesList | ||
indices={ | ||
Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
Object { | ||
"name": "es", | ||
}, | ||
] | ||
} | ||
/> | ||
</EuiPanel> | ||
`; | ||
exports[`StepIndexPattern should render some indices 1`] = ` | ||
<EuiPanel | ||
grow={true} | ||
hasShadow={false} | ||
paddingSize="l" | ||
> | ||
<Header | ||
characterList="\\\\, /, ?, \\", <, >, |" | ||
errors={Array []} | ||
goToNextStep={[Function]} | ||
isInputInvalid={false} | ||
isNextStepDisabled={false} | ||
onQueryChanged={[Function]} | ||
query="k*" | ||
/> | ||
<EuiSpacer | ||
size="s" | ||
/> | ||
<StatusMessage | ||
matchedIndices={ | ||
Object { | ||
"allIndices": Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
Object { | ||
"name": "es", | ||
}, | ||
], | ||
"exactMatchedIndices": Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
], | ||
"partialMatchedIndices": Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
], | ||
"visibleIndices": Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
], | ||
} | ||
} | ||
query="k*" | ||
/> | ||
<EuiSpacer | ||
size="s" | ||
/> | ||
<IndicesList | ||
indices={ | ||
Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
] | ||
} | ||
/> | ||
</EuiPanel> | ||
`; | ||
exports[`StepIndexPattern should render the loading state 1`] = ` | ||
<EuiPanel | ||
grow={true} | ||
hasShadow={false} | ||
paddingSize="l" | ||
> | ||
<Header | ||
characterList="\\\\, /, ?, \\", <, >, |" | ||
errors={Array []} | ||
goToNextStep={[Function]} | ||
isInputInvalid={false} | ||
isNextStepDisabled={true} | ||
onQueryChanged={[Function]} | ||
query="k" | ||
/> | ||
<EuiSpacer | ||
size="s" | ||
/> | ||
<LoadingIndices /> | ||
<EuiSpacer | ||
size="s" | ||
/> | ||
</EuiPanel> | ||
`; | ||
exports[`StepIndexPattern should show errors 1`] = ` | ||
<EuiPanel | ||
grow={true} | ||
hasShadow={false} | ||
paddingSize="l" | ||
> | ||
<Header | ||
characterList="\\\\, /, ?, \\", <, >, |" | ||
errors={ | ||
Array [ | ||
"Your input contains invalid characters or spaces. Please omit: \\\\, /, ?, \\", <, >, |", | ||
] | ||
} | ||
goToNextStep={[Function]} | ||
isInputInvalid={true} | ||
isNextStepDisabled={true} | ||
onQueryChanged={[Function]} | ||
query="?" | ||
/> | ||
<EuiSpacer | ||
size="s" | ||
/> | ||
<StatusMessage | ||
matchedIndices={ | ||
Object { | ||
"allIndices": Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
Object { | ||
"name": "es", | ||
}, | ||
], | ||
"exactMatchedIndices": Array [], | ||
"partialMatchedIndices": Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
], | ||
"visibleIndices": Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
], | ||
} | ||
} | ||
query="?" | ||
/> | ||
<EuiSpacer | ||
size="s" | ||
/> | ||
<IndicesList | ||
indices={ | ||
Array [ | ||
Object { | ||
"name": "kibana", | ||
}, | ||
] | ||
} | ||
/> | ||
</EuiPanel> | ||
`; |
96 changes: 96 additions & 0 deletions
96
...e_index_pattern_wizard/components/step_index_pattern/__tests__/step_index_pattern.test.js
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,96 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import { StepIndexPattern } from '../step_index_pattern'; | ||
|
||
jest.mock('../components/indices_list', () => ({ IndicesList: 'IndicesList' })); | ||
jest.mock('../components/loading_indices', () => ({ LoadingIndices: 'LoadingIndices' })); | ||
jest.mock('../components/status_message', () => ({ StatusMessage: 'StatusMessage' })); | ||
jest.mock('../components/header', () => ({ Header: 'Header' })); | ||
jest.mock('../../../lib/create_reasonable_wait', () => ({ createReasonableWait: fn => fn() })); | ||
jest.mock('../../../lib/get_indices', () => ({ | ||
getIndices: () => { | ||
return [ | ||
{ name: 'kibana' }, | ||
]; | ||
}, | ||
})); | ||
|
||
const allIndices = [{ name: 'kibana' }, { name: 'es' }]; | ||
const esService = {}; | ||
const goToNextStep = () => {}; | ||
|
||
describe('StepIndexPattern', () => { | ||
it('should render normally', () => { | ||
const component = shallow( | ||
<StepIndexPattern | ||
allIndices={allIndices} | ||
isIncludingSystemIndices={false} | ||
esService={esService} | ||
goToNextStep={goToNextStep} | ||
initialQuery={'k'} | ||
/> | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render the loading state', () => { | ||
const component = shallow( | ||
<StepIndexPattern | ||
allIndices={allIndices} | ||
isIncludingSystemIndices={false} | ||
esService={esService} | ||
goToNextStep={goToNextStep} | ||
/> | ||
); | ||
|
||
component.setState({ query: 'k', isLoadingIndices: true }); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render some indices', async () => { | ||
const component = shallow( | ||
<StepIndexPattern | ||
allIndices={allIndices} | ||
isIncludingSystemIndices={false} | ||
esService={esService} | ||
goToNextStep={goToNextStep} | ||
/> | ||
); | ||
|
||
const instance = component.instance(); | ||
|
||
await instance.onQueryChanged({ | ||
nativeEvent: { data: 'k' }, | ||
target: { value: 'k' } | ||
}); | ||
|
||
component.update(); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('should show errors', async () => { | ||
const component = shallow( | ||
<StepIndexPattern | ||
allIndices={allIndices} | ||
isIncludingSystemIndices={false} | ||
esService={esService} | ||
goToNextStep={goToNextStep} | ||
/> | ||
); | ||
|
||
const instance = component.instance(); | ||
|
||
await instance.onQueryChanged({ | ||
nativeEvent: { data: '?' }, | ||
target: { value: '?' } | ||
}); | ||
|
||
component.update(); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.