import type * as ts from 'typescript' ; import { Scope } from '../../scope/scope' ; import { core } from '../../core/core' ; import { GetDescriptor } from '../descriptor' ; import { IsTypescriptType } from '../tsLibs/typecriptLibs' ; import { GetMockCall } from './mockCall' ; import { GetMockPropertiesAssignments , PropertyAssignments , } from './mockPropertiesAssignments' ; import { PropertyLike } from './propertyLike' ; import { SignatureLike } from './signatureLike' ; export function GetMockPropertiesFromSymbol ( propertiesSymbol , signatures , scope ) { const properties = propertiesSymbol . filter ( ( prop ) => ! ! prop . declarations ) . map ( ( prop ) => prop . declarations ?. filter ( ( declaration ) => ! core . ts . isSetAccessor ( declaration ) ) [ 0 ] ) . filter ( Boolean ) as PropertyLike [ ] ; const signaturesDeclarations = signatures . map ( ( signature ) => signature . declaration ) as SignatureLike [ ] ; return GetMockPropertiesFromDeclarations ( properties , signaturesDeclarations , scope ) ; } export function GetMockPropertiesFromDeclarations ( list , signatures , scope ) { const propertiesFilter = list . filter ( ( member ) => { const modifiers = member . modifiers ; if ( IsTypescriptType ( member ) ) { return false ; } if ( member . questionToken && ! scope . hydrated ) { return false ; } if ( ! modifiers ) { return true ; } return ( modifiers . filter ( ( modifier ) => modifier . kind === core . ts . SyntaxKind . PrivateKeyword ) . length === 0 ) ; } ) ; const accessorDeclaration = GetMockPropertiesAssignments ( propertiesFilter , scope ) ; const signaturesDescriptor = signatures . length ? GetDescriptor ( signatures [ 0 ] , scope ) : null ; return GetMockCall ( accessorDeclaration , signaturesDescriptor ) ; }