import React from 'react' ; import { shallow } from 'enzyme' ; import { ApiKey } from '../api_key' ; import { CredentialItem } from '../credential_item' ; import { SourceConfigFields } from './' ; describe ( 'SourceConfigFields' , ( ) => { it ( 'renders empty with no items' , ( ) => { const wrapper = shallow ( < SourceConfigFields />); expect ( wrapper . find ( ApiKey ) ) . toHaveLength ( 0 ) ; expect ( wrapper . find ( CredentialItem ) ) . toHaveLength ( 0 ) ; } ) ; it ( 'renders with all items, hiding API Keys' , ( ) => { const wrapper = shallow ( < SourceConfigFields isOauth1 = { false } clientId = "123" clientSecret = "456" publicKey = "abc" consumerKey = "def" baseUrl = "ghi" / > ) ; expect ( wrapper . find ( ApiKey ) ) . toHaveLength ( 0 ) ; expect ( wrapper . find ( CredentialItem ) ) . toHaveLength ( 3 ) ; } ) ; it ( 'shows API keys' , ( ) => { const wrapper = shallow ( < SourceConfigFields isOauth1 clientSecret = "456" publicKey = "abc" consumerKey = "def" baseUrl = "ghi" / > ) ; expect ( wrapper . find ( ApiKey ) ) . toHaveLength ( 2 ) ; } ) ; } ) ;