import React from 'react' ; import { ServerStatus } from './server_status' ; import { FormattedStatus } from '../lib' ; import { mountWithIntl } from 'test_utils/enzyme_helpers' ; const getStatus = ( parts = { } ) : FormattedStatus [ 'state' ] => ( { id : 'green' , title : 'Green' , uiColor : 'secondary' , message : '' , ... parts , } ) ; describe ( 'ServerStatus' , ( ) => { it ( 'renders correctly for green state' , ( ) => { const status = getStatus ( ) ; const component = mountWithIntl ( < ServerStatus serverState = { status } name = "My Computer" / > ) ; expect ( component . find ( 'EuiTitle' ) . text ( ) ) . toMatchInlineSnapshot ( `"OpenSearch Dashboards status is Green"` ) ; expect ( component . find ( 'EuiBadge' ) ) . toMatchSnapshot ( ) ; } ) ; it ( 'renders correctly for red state' , ( ) => { const status = getStatus ( { id : 'red' , title : 'Red' , } ) ; const component = mountWithIntl ( < ServerStatus serverState = { status } name = "My Computer" / > ) ; expect ( component . find ( 'EuiTitle' ) . text ( ) ) . toMatchInlineSnapshot ( `"OpenSearch Dashboards status is Red"` ) ; expect ( component . find ( 'EuiBadge' ) ) . toMatchSnapshot ( ) ; } ) ; it ( 'displays the correct `name`' , ( ) => { let component = mountWithIntl ( < ServerStatus serverState = { getStatus ( ) } name = "Localhost" / > ) ; expect ( component . find ( 'EuiText' ) . text ( ) ) . toMatchInlineSnapshot ( `"Localhost"` ) ; component = mountWithIntl ( < ServerStatus serverState = { getStatus ( ) } name = "OpenSearchDashboards" / > ) ; expect ( component . find ( 'EuiText' ) . text ( ) ) . toMatchInlineSnapshot ( `"OpenSearchDashboards"` ) ; } ) ; } ) ;