[Uptime] only render ping status code badge when status code is available (#87096)

* uptime only render ping status code badge when status code is available

* uptime update ResponseCodeColumn error state

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Dominique Clarke 2021-01-05 12:45:59 -05:00 committed by GitHub
parent eabd7088bb
commit 16ad4d6685
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View file

@ -0,0 +1,25 @@
/*
* 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 React from 'react';
import { render } from '@testing-library/react';
import { ResponseCodeColumn } from '../columns/response_code';
describe('ResponseCodeColumn', () => {
const statusCode = '200';
it('render when statusCode is available', () => {
const { getByText } = render(<ResponseCodeColumn statusCode={statusCode} />);
expect(getByText(statusCode)).toBeInTheDocument();
});
it('renders error content when statusCode is unavailable', () => {
const { queryByText } = render(<ResponseCodeColumn statusCode={''} />);
expect(queryByText('--')).toBeInTheDocument();
});
});

View file

@ -19,7 +19,7 @@ interface Props {
export const ResponseCodeColumn = ({ statusCode }: Props) => {
return (
<SpanWithMargin>
<EuiBadge>{statusCode}</EuiBadge>
{statusCode ? <EuiBadge data-test-subj="pingResponseCode">{statusCode}</EuiBadge> : '--'}
</SpanWithMargin>
);
};