UNPKG

3.38 kBTypeScriptView Raw
1/// <reference types="node" />
2import { ExecutionContext } from 'ava';
3export { readJsonFile as readJsonFixture } from './FileUtils';
4export declare const inTestMode: (env?: NodeJS.ProcessEnv) => boolean;
5/**
6 * Helper function to throw error for unit test exports
7 * @throws {Error}
8 */
9export declare const throwTestError: () => never;
10/**
11 * Generate a [40 character] random string
12 *
13 * @param {number} numBytes - number of bytes to use in creating a random string
14 * defaults to 20 to produce a 40 character string
15 * @returns {string} - a random string
16 */
17export declare const randomString: (numBytes?: number) => string;
18/**
19 * Postpend a [10-character] random string to input identifier.
20 *
21 * @param {string} id - identifer to return
22 * @param {number} numBytes - number of bytes to use to compute random
23 * extension. Default 5 to produce 10 characters..
24 * @returns {string} - a random string
25 */
26export declare const randomId: (id: string, numBytes?: number) => string;
27/**
28 * Generate a random for the given scale.
29 *
30 * Defaults to a number between 1 and 10.
31 *
32 * @param {number} scale - scale for the random number. Defaults to 10.
33 * @returns {number} - a random number
34 */
35export declare const randomNumber: (scale?: number) => number;
36/**
37 * Create a random granule id from the regular expression
38 *
39 * @param {string} regex - regular expression string
40 * @returns {string} - random granule id
41 */
42export declare const randomStringFromRegex: (regex: string) => string;
43/**
44 * Validate a task input object using json-schema
45 *
46 * Issues a test failure if there were validation errors
47 *
48 * @param {Object} t - an ava test
49 * @param {Object} data - the object to be validated
50 * @returns {Promise<undefined>}
51 */
52export declare function validateInput(t: ExecutionContext, data: unknown): Promise<void>;
53/**
54 * Validate a task config object using json-schema
55 *
56 * Issues a test failure if there were validation errors
57 *
58 * @param {Object} t - an ava test
59 * @param {Object} data - the object to be validated
60 * @returns {Promise<undefined>}
61 */
62export declare function validateConfig(t: ExecutionContext, data: unknown): Promise<void>;
63/**
64 * Validate a task output object using json-schema
65 *
66 * Issues a test failure if there were validation errors
67 *
68 * @param {Object} t - an ava test
69 * @param {Object} data - the object to be validated
70 * @returns {Promise<undefined>}
71 */
72export declare function validateOutput(t: ExecutionContext, data: unknown): Promise<void>;
73/**
74 * Determine the path of the current git repo
75 *
76 * @param {string} dirname - the directory that you're trying to find the git
77 * root for
78 * @returns {Promise.<string>} - the filesystem path of the current git repo
79 */
80export declare function findGitRepoRootDirectory(dirname: string): Promise<string>;
81/**
82 * Determine the path of the packages/test-data directory
83 *
84 * @returns {Promise.<string>} - the filesystem path of the packages/test-data
85 * directory
86 */
87export declare function findTestDataDirectory(): Promise<string>;
88/**
89 * Prettify and display something to the console.
90 *
91 * This is only intended to be used during debugging.
92 *
93 * @param {Object|Array} object - an object or array to be stringifyed
94 * @returns {undefined} - no return value
95 */
96export declare function jlog(object: unknown): void;
97//# sourceMappingURL=test-utils.d.ts.map
\No newline at end of file