import React from 'react' ; import { shallow } from 'enzyme' ; import { EuiFlyout } from '@elastic/eui' ; import { ROLE_MAPPING_FLYOUT_CREATE_TITLE , ROLE_MAPPING_FLYOUT_UPDATE_TITLE , ROLE_MAPPING_FLYOUT_CREATE_BUTTON , ROLE_MAPPING_FLYOUT_UPDATE_BUTTON , } from './constants' ; import { RoleMappingFlyout } from './role_mapping_flyout' ; describe ( 'RoleMappingFlyout' , ( ) => { const closeUsersAndRolesFlyout = jest . fn ( ) ; const handleSaveMapping = jest . fn ( ) ; const props = { isNew : true , disabled : false , formLoading : false , closeUsersAndRolesFlyout , handleSaveMapping , } ; it ( 'renders for new mapping' , ( ) => { const wrapper = shallow ( < RoleMappingFlyout { ... props } > < div /> < /RoleMappingFlyout>); expect ( wrapper . find ( EuiFlyout ) ) . toHaveLength ( 1 ) ; expect ( wrapper . find ( '[data-test-subj="FlyoutTitle"]' ) . prop ( 'children' ) ) . toEqual ( ROLE_MAPPING_FLYOUT_CREATE_TITLE ) ; expect ( wrapper . find ( '[data-test-subj="FlyoutButton"]' ) . prop ( 'children' ) ) . toEqual ( ROLE_MAPPING_FLYOUT_CREATE_BUTTON ) ; } ) ; it ( 'renders for existing mapping' , ( ) => { const wrapper = shallow ( < RoleMappingFlyout { ... props } isNew = { false } > < div /> < /RoleMappingFlyout>); expect ( wrapper . find ( EuiFlyout ) ) . toHaveLength ( 1 ) ; expect ( wrapper . find ( '[data-test-subj="FlyoutTitle"]' ) . prop ( 'children' ) ) . toEqual ( ROLE_MAPPING_FLYOUT_UPDATE_TITLE ) ; expect ( wrapper . find ( '[data-test-subj="FlyoutButton"]' ) . prop ( 'children' ) ) . toEqual ( ROLE_MAPPING_FLYOUT_UPDATE_BUTTON ) ; } ) ; } ) ;