1 | /// <reference types="node" />
|
2 | import * as events from "events";
|
3 | import { NilCallback } from "util.toolbox";
|
4 | export interface PatternOpts {
|
5 | columns?: number;
|
6 | chevrons?: string[];
|
7 | repeat?: number;
|
8 | }
|
9 | export interface FixtureOpts {
|
10 | basedir?: string;
|
11 | dataFile?: string;
|
12 | fixtureDirectory?: string;
|
13 | jsonFile?: string;
|
14 | yamlFile?: string;
|
15 | script?: string;
|
16 | templateData?: {
|
17 | [name: string]: string;
|
18 | };
|
19 | loremIpsum?: any;
|
20 | pattern?: PatternOpts;
|
21 | }
|
22 | export interface FixtureCallback extends NilCallback {
|
23 | (err: Error | null, directories: string[] | any): void | null;
|
24 | }
|
25 | /** Creates an instance of a fixture */
|
26 | export declare class Fixture extends events.EventEmitter {
|
27 | /**
|
28 | * Removes all of the temporary directories that were created by fixtures
|
29 | * in test cases. Each fixture registers the directory it created when it
|
30 | * was instantiated. This will iterate through all of those directories and
|
31 | * remove them. It should be called as the last step in any testing.
|
32 | * @param [cb] {FixtureCallback} a callback function exectued when the cleanup
|
33 | * procedure is complete. The callback parameters are:
|
34 | *
|
35 | * - err {Error}: error object if an error has occurred. Null if no error has
|
36 | * occurred.
|
37 | * - directories {string[]}: a list of the directories that were removed.
|
38 | *
|
39 | */
|
40 | static cleanup(cb?: FixtureCallback): void;
|
41 | private _basedir;
|
42 | private _dir;
|
43 | private _data;
|
44 | private _files;
|
45 | private _json;
|
46 | private _jsonObj;
|
47 | private _loremIpsum;
|
48 | private _name;
|
49 | private _obj;
|
50 | private _opts;
|
51 | private _pattern;
|
52 | private _src;
|
53 | private _yaml;
|
54 | private _yamlObj;
|
55 | /**
|
56 | * Creates an instance of a fixture object for use in a unit test. By
|
57 | * default it looks lin ./test/fixtures.
|
58 | * @param [name] {string} the name of the fixture to load
|
59 | * @param [opts] {FixtureOpts} optional arguments (see README for details)
|
60 | * @constructor
|
61 | */
|
62 | constructor(name?: string, opts?: FixtureOpts);
|
63 | /**
|
64 | * Generates a test pattern string. The generated string is created from a
|
65 | * list of chevrons. Each chevron is a full row of N columns. The default
|
66 | * string is 26 rows with 80 columns, where each default chevron is A-Z
|
67 | */
|
68 | private patternGenerator;
|
69 | /**
|
70 | * Takes a file name within the fixture, and reads the contents of the
|
71 | * file into a buffer and returns it. This is the name of the relative path
|
72 | * and file within the fixture.
|
73 | * @param filename {string} the name of the file within the fixture to read.
|
74 | * string representing the contents of the requested file.
a |
75 | */
|
76 | read(filename: string): string;
|
77 | /**
|
78 | * Sets the base location for the temporariy files that this Fixture instance
|
79 | * will use.
|
80 | * @returns {string} the path location for the base directory
|
81 | */
|
82 | setBaseDirectory(): string;
|
83 | /**
|
84 | * Returns a string representation of the internal object structure of
|
85 | * the Fixture.
|
86 | * @returns {string} the string representing the object.
|
87 | */
|
88 | toString(): string;
|
89 | basedir: string;
|
90 | readonly data: string[];
|
91 | readonly dir: string;
|
92 | readonly files: string[];
|
93 | readonly json: string;
|
94 | readonly jsonObj: any;
|
95 | readonly loremIpsum: string;
|
96 | readonly name: string;
|
97 | readonly obj: any;
|
98 | readonly pattern: string;
|
99 | readonly src: string;
|
100 | readonly yaml: string;
|
101 | readonly yamlObj: any;
|
102 | }
|
103 | /**
|
104 | * Convenience wrapper function used by testing scripts to perform cleanup of
|
105 | * temporary files. Typically this would be used in the "afterAll" call of
|
106 | * a jest test (or the test function executed at the end of all testing)
|
107 | * @param options=null {any} - general options for the cleanup
|
108 | * @param [options.done=null] {any} - a callback semaphore used by async tests to signal
|
109 | * that processing is "done" to the testing framework.
|
110 | * @param [options.message=""] {string} - a message that will be printed to the console
|
111 | * when this cleanup operation is executed.
|
112 | */
|
113 | export declare function cleanup(options?: any): void;
|
114 | export default Fixture;
|