import { generateMapping } from './manage_schema' ; import { parsedWorkingCollector } from './__fixture__/parsed_working_collector' ; import * as path from 'path' ; import { readFile } from 'fs' ; import { promisify } from 'util' ; const read = promisify ( readFile ) ; async function parseJsonFile ( relativePath ) { const schemaPath = path . resolve ( __dirname , '__fixture__' , relativePath ) ; const fileContent = await read ( schemaPath , 'utf8' ) ; return JSON . parse ( fileContent ) ; } describe ( 'generateMapping' , ( ) => { it ( 'generates a mapping file' , async ( ) => { const mockSchema = await parseJsonFile ( 'mock_schema.json' ) ; const result = generateMapping ( [ parsedWorkingCollector ] ) ; expect ( result ) . toEqual ( mockSchema ) ; } ) ; } ) ;