import { sync as globSync } from 'glob' ; import { join } from 'path' ; import { readFileSync } from 'fs' ; import { codec } from '../src/codec' ; import { buildTestCases } from './utils' ; const files = globSync ( join ( __dirname , '..' , 'fixtures' , '*_decodings.json' ) ) . map ( p => JSON . parse ( readFileSync ( p , 'utf8' ) ) as { title : string ; testCases : { description : string ; input : { value : string ; schema : any ; } ; output : { object : object ; } ; } [ ] ; } ) ; describe ( 'decodeJSON' , ( ) => { describe . each ( buildTestCases ( files ) ) ( '%s' , file => { it . each ( buildTestCases ( file . testCases ) ) ( '%s' , ( { input , output } ) => { expect ( codec . decodeJSON ( input . schema , Buffer . from ( input . value , 'hex' ) ) ) . toEqual ( output . object ) ; } ) ; } ) ; } ) ;