[ML] Fixes jest tests for bucket span estimator button. (#19164)

Fixes jest tests for the bucket span estimator button. The tests were not correctly considering the way jest runs tests asynchronously. Now each test is self-contained within the test callback.
This commit is contained in:
Walter Rafelsberger 2018-05-17 14:04:18 +02:00 committed by GitHub
parent 69b857ca54
commit 72083c9b0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 20 deletions

View file

@ -10,15 +10,15 @@ exports[`BucketSpanEstimator renders the button 1`] = `
>
<EuiButton
color="primary"
disabled={true}
disabled={false}
fill={true}
iconSide="right"
isLoading={true}
isLoading={false}
onClick={[Function]}
size="s"
type="button"
>
Estimating bucket span
Estimate bucket span
</EuiButton>
</EuiToolTip>
</div>

View file

@ -10,29 +10,26 @@ import React from 'react';
import { BucketSpanEstimator } from './bucket_span_estimator_view';
describe('BucketSpanEstimator', () => {
const props = {
buttonDisabled: false,
estimatorRunning: false,
guessBucketSpan: () => {},
buttonText: 'Estimate bucket span'
};
const component = (
<BucketSpanEstimator {...props} />
);
const wrapper = shallow(component);
test('renders the button', () => {
const props = {
buttonDisabled: false,
estimatorRunning: false,
guessBucketSpan: () => { },
buttonText: 'Estimate bucket span'
};
const wrapper = shallow(<BucketSpanEstimator {...props} />);
expect(wrapper).toMatchSnapshot();
});
props.buttonDisabled = true;
props.estimatorRunning = true;
props.buttonText = 'Estimating bucket span';
wrapper.setProps(props);
test('renders the loading button', () => {
const props = {
buttonDisabled: true,
estimatorRunning: true,
guessBucketSpan: () => { },
buttonText: 'Estimating bucket span'
};
const wrapper = shallow(<BucketSpanEstimator {...props} />);
expect(wrapper).toMatchSnapshot();
});
});