import { strict as assert } from "assert" ; import { generatePairwiseOptions , OptionsMatrix } from "../index" ; describe ( "generatePairwiseOptions.examples" , ( ) => { it ( "Testing a function" , ( ) => { const myFunction = ( param1 , param2 , param3 ? ) => { } ; const options = generatePairwiseOptions < { p1 : boolean ; p2 : "string1" | "string2" ; p3 ? : number ; } > ( { p1 : [ true , false ] , p2 : [ "string1" , "string2" ] , p3 : [ undefined , 0 , 10 , 100 ] } ) ; for ( const option of options ) { myFunction ( option . p1 , option . p2 , option . p3 ) ; } } ) ; it ( "Testing an object" , ( ) => { interface MyObject { prop1 : boolean ; prop2 ? : number ; prop3 ? : string ; } const myObjectMatrix = { prop1 : [ true , false ] , prop2 : [ undefined , 37 , 242 ] , prop3 : [ undefined ] } ; const myObjects = generatePairwiseOptions < MyObject > ( myObjectMatrix ) ; const runScenario = ( instance ) => { } ; for ( const instance of myObjects ) { runScenario ( instance ) ; } } ) ; it ( "Generate a fixed length Array" , ( ) => { const arrayMatrix = { 0 : [ 3 , 6 , 9 , 12 , 15 ] , 1 : [ 7 , 14 , 28 ] , length : [ 2 ] } ; const myArrayLikes = generatePairwiseOptions < ArrayLike < number > > ( arrayMatrix ) ; const runScenario = ( numbers ) => { assert . strictEqual ( numbers . length , 2 ) ; assert ( numbers [ 0 ] % 3 === 0 ) ; assert ( numbers [ 1 ] % 7 === 0 ) ; } ; for ( const arrayLike of myArrayLikes ) { runScenario ( Array . from ( arrayLike ) ) ; } } ) ; it ( "Generate an Complex object using nested options matrices" , ( ) => { const arrayMatrix = { 0 : [ 3 , 6 , 9 , 12 , 15 ] , 1 : [ 7 , 14 , 28 ] , length : [ 2 ] } ; interface MyComplexObject { numbers ? : number [ ] ; subObject : { str : string ; } ; } const complexObjectMatrix = { numbers : [ undefined , ... generatePairwiseOptions < ArrayLike < number > > ( arrayMatrix ) . map ( ( a ) => Array . from ( a ) ) ] , subObject : generatePairwiseOptions < { str : string ; } > ( { str : [ "a" , "b" , "c" ] } ) } ; const complexObjects = generatePairwiseOptions < MyComplexObject > ( complexObjectMatrix ) ; const runScenario = ( complexObject ) => { } ; for ( const complexObject of complexObjects ) { runScenario ( complexObject ) ; } } ) ; } ) ;