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 (elastic#87096)

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

* uptime update ResponseCodeColumn error state

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dominiqueclarke and kibanamachine committed Jan 5, 2021
1 parent 497383d commit e85a9d1
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 e85a9d1

Please sign in to comment.