import { readFileSync , readdirSync } from 'fs' ; import { join } from 'path' ; class TestRoot { constructor ( public baseDir , ... paths ) { this . baseDir = join ( baseDir , ... paths ) ; } file ( ... paths ) { return new TestFile ( this . baseDir , ... paths ) ; } directory ( ... paths ) { return new TestDirectory ( this . baseDir , ... paths ) ; } } class TestFile { filePath : string ; contents : string ; constructor ( public baseDir , ... paths ) { this . filePath = join ( this . baseDir , ... paths ) ; this . contents = readFileSync ( this . filePath , 'utf-8' ) ; } } class TestDirectory { dirPath : string ; contents : string [ ] ; constructor ( public baseDir , ... paths ) { this . dirPath = join ( this . baseDir , ... paths ) ; this . contents = readdirSync ( this . dirPath ) ; } } param { string } baseDir param { ... string [ ] } paths returns { TestRoot } export function testRoot ( baseDir , ... paths ) { return new TestRoot ( baseDir , ... paths ) ; }