/// import * as events from "events"; import { NilCallback } from "util.toolbox"; export interface PatternOpts { columns?: number; chevrons?: string[]; repeat?: number; } export interface FixtureOpts { basedir?: string; dataFile?: string; fixtureDirectory?: string; jsonFile?: string; yamlFile?: string; script?: string; templateData?: { [name: string]: string; }; loremIpsum?: any; pattern?: PatternOpts; } export interface FixtureCallback extends NilCallback { (err: Error | null, directories: string[] | any): void | null; } /** Creates an instance of a fixture */ export declare class Fixture extends events.EventEmitter { /** * Removes all of the temporary directories that were created by fixtures * in test cases. Each fixture registers the directory it created when it * was instantiated. This will iterate through all of those directories and * remove them. It should be called as the last step in any testing. * @param [cb] {FixtureCallback} a callback function exectued when the cleanup * procedure is complete. The callback parameters are: * * - err {Error}: error object if an error has occurred. Null if no error has * occurred. * - directories {string[]}: a list of the directories that were removed. * */ static cleanup(cb?: FixtureCallback): void; private _basedir; private _dir; private _data; private _files; private _json; private _jsonObj; private _loremIpsum; private _name; private _obj; private _opts; private _pattern; private _src; private _yaml; private _yamlObj; /** * Creates an instance of a fixture object for use in a unit test. By * default it looks lin ./test/fixtures. * @param [name] {string} the name of the fixture to load * @param [opts] {FixtureOpts} optional arguments (see README for details) * @constructor */ constructor(name?: string, opts?: FixtureOpts); /** * Generates a test pattern string. The generated string is created from a * list of chevrons. Each chevron is a full row of N columns. The default * string is 26 rows with 80 columns, where each default chevron is A-Z */ private patternGenerator; /** * Takes a file name within the fixture, and reads the contents of the * file into a buffer and returns it. This is the name of the relative path * and file within the fixture. * @param filename {string} the name of the file within the fixture to read. * @returns a string representing the contents of the requested file. */ read(filename: string): string; /** * Sets the base location for the temporariy files that this Fixture instance * will use. * @returns {string} the path location for the base directory */ setBaseDirectory(): string; /** * Returns a string representation of the internal object structure of * the Fixture. * @returns {string} the string representing the object. */ toString(): string; basedir: string; readonly data: string[]; readonly dir: string; readonly files: string[]; readonly json: string; readonly jsonObj: any; readonly loremIpsum: string; readonly name: string; readonly obj: any; readonly pattern: string; readonly src: string; readonly yaml: string; readonly yamlObj: any; } /** * Convenience wrapper function used by testing scripts to perform cleanup of * temporary files. Typically this would be used in the "afterAll" call of * a jest test (or the test function executed at the end of all testing) * @param options=null {any} - general options for the cleanup * @param [options.done=null] {any} - a callback semaphore used by async tests to signal * that processing is "done" to the testing framework. * @param [options.message=""] {string} - a message that will be printed to the console * when this cleanup operation is executed. */ export declare function cleanup(options?: any): void; export default Fixture;