import { getAllure } from "../core" ; import { processDescriptor } from "../core/descriptor" ; /**
 * This code was partially cloned from testdeck/core package and improved to support missing data tracking features.
 */ const nodeSymbol = ( key ) : string => `__testdeck_${ key }` ; const testNameSymbol = nodeSymbol ( "name" ) ; const parametersSymbol = nodeSymbol ( "parametersSymbol" ) ; const nameForParametersSymbol = nodeSymbol ( "nameForParameters" ) ; type Params = any | ( ( arg ? : any ) => any ) ; type Execution = undefined | "pending" | "only" | "skip" | "execution" ; type TestDecorator = ( target : unknown , property : string , descriptor : PropertyDescriptor ) => PropertyDescriptor ; type ParamsDecorator = ( params : Params , name ? : string ) => TestDecorator ; interface ParameterizedPropertyDescriptor extends PropertyDescriptor { ( params , name ? ) : MethodDecorator ; skip ( params , name ? ) : MethodDecorator ; only ( params , name ? ) : MethodDecorator ; pending ( params , name ? ) : MethodDecorator ; naming ( nameForParameters ) : MethodDecorator ; } const makeParamsNameFunction = ( ) : any => { return ( nameForParameters ) => ( target , propertyKey , descriptor ) => { target [ propertyKey ] [ nameForParametersSymbol ] = nameForParameters ; return descriptor ; } ; } ; const makeParamsFunction = < T > ( execution ? ) : ParamsDecorator => { return ( params , name ? ) => ( target , propertyKey , descriptor ) => { const adjustedParams = typeof params === "function" ? params ( ) : params ; target [ propertyKey ] [ testNameSymbol ] = propertyKey . toString ( ) ; target [ propertyKey ] [ parametersSymbol ] = target [ propertyKey ] [ parametersSymbol ] || [ ] ; [ ] . concat ( adjustedParams || [ ] ) . forEach ( ( param ) => { target [ propertyKey ] [ parametersSymbol ] . push ( { execution , name , params : param } ) ; } ) ; return processDescriptor < T > ( ( args ) => JSON . stringify ( args ) , ( arg ) => getAllure ( ) . parameter ( "inputs" , arg ) , descriptor , ( prop ) => prop . startsWith ( "__testdeck_" ) ) ; } ; } ; const makeParamsObject = ( ) : any => { return Object . assign ( makeParamsFunction ( ) , { only : makeParamsFunction ( "only" ) , pending : makeParamsFunction ( "pending" ) , skip : makeParamsFunction ( "skip" ) , naming : makeParamsNameFunction ( ) , } ) ; } ; export const data = makeParamsObject ( ) ;