import type * as ts from 'typescript' ; import { createArrayLiteral } from '../../typescriptFactory/typescriptFactory' ; import { CustomFunction } from '../matcher/matcher' ; import { getMock } from '../mock/mock' ; import { customFunctionWithTypeArgument } from './helpers/custom-function-with-type-argument' ; export const createMockListCustomFunction = customFunctionWithTypeArgument ( 'create-mock-list.d.ts' , 'createMockList' , ( node , nodeToMock ) : ts . Node => { const lengthExpression = node . arguments [ 0 ] ; if ( ! lengthExpression ) { return createArrayLiteral ( [ ] ) ; } return getMock ( node , { nodeToMock , amount : lengthExpression , defaultValues : getDefaultValues ( node ) , } ) ; } ) ; function getDefaultValues ( node ) { return ! ! node . arguments . length ? node . arguments [ 1 ] : undefined ; }