import * as React from 'react'; import Markdown from '../Markdown'; import { FieldsDocumentation } from './fields-documentation'; import { Code } from '../Sections/views/import-example/Code'; import { flatten } from './flatten'; import { makeImportCode } from './make-import-code'; import { Descriptor } from './typings'; import { Testkit } from '../typings/config'; import { Metadata } from '../typings/metadata'; const extractNested = (descriptors: Descriptor[]) => descriptors.reduce( (acc, descriptor) => { descriptor.type === 'object' ? acc.nested.push(descriptor) : acc.flat.push(descriptor); return acc; }, { flat: [], nested: [] }, ); interface Props { dataHook?: string; descriptor: any; metadata: Metadata; testkitConfig?: Testkit; title: string; unidriver: boolean; hideImport?: boolean | undefined; } export const DriverDocumentation: React.FunctionComponent = ({ dataHook, descriptor, metadata, testkitConfig, title, unidriver, hideImport, }) => { const { nested, flat } = extractNested(descriptor); return (

{title}

{testkitConfig && !hideImport && ( {makeImportCode({ testkit: testkitConfig, metadata })} )} {unidriver && ( **NOTE**: All UniDriver methods are asynchronous, use them with \`async\`/\`await\`!`} /> )} {flat.length > 0 && (
)} {nested.length > 0 && (

This Testkit has nested API

{nested.map(({ name, props }) => (
))}
)}
); };