Skip to content

Commit

Permalink
[Uptime] only render ping status code badge when status code is avail…
Browse files Browse the repository at this point in the history
…able (#87096) (#87360)

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

* uptime update ResponseCodeColumn error state

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dominiqueclarke and kibanamachine authored Jan 5, 2021
1 parent 83f332c commit f1a1bb9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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>
);
};

0 comments on commit f1a1bb9

Please sign in to comment.