Skip to content

Commit

Permalink
types(vest): fix schema types
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Jan 30, 2021
1 parent 6471856 commit d6cce23
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/vest/src/typings/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare function getFn(fieldName: string): string[];
declare function getFn(): { [fieldName: string]: string[] };

declare interface schema {
declare const schema: {
(enforceSchema: any, body?: (...args: any[]) => void): (
data: any
) => {
Expand All @@ -21,6 +21,6 @@ declare interface schema {

skip: (namespace: string) => void;
only: (namespace: string) => void;
}
};

export default schema;
24 changes: 14 additions & 10 deletions packages/vest/src/typings/vest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type MessageFunc = (...args: any[]) => string;
type ExclusionArg = string | string[] | void;

export = vest;
export as namespace React;
export as namespace vest;

interface VestTest {
failed: boolean;
Expand All @@ -21,23 +21,27 @@ interface VestTest {

interface ITestEach {
/**
* Run multiple tests using a parameter table
* Run multiple tests using a parameter table
* @param {String} fieldName Name of the field to test.
* @param {String|function} message The message returned in case of a failure. Follows printf syntax.
* @param {function} testFn The actual test callback.
*
*
* @example
*
*
* test.each([[1,2,3],[2,1,3]])('test', (a, b, c) => `${a} + ${b} does not equal ${c}`, (a, b, c) => enforce(a + b).equals(c));
*/
(fieldName: string | MessageFunc, message: string | MessageFunc, testFn: TestArgsCB): VestTest[];
(
fieldName: string | MessageFunc,
message: string | MessageFunc,
testFn: TestArgsCB
): VestTest[];
/**
* Run multiple tests using a parameter table
* Run multiple tests using a parameter table
* @param {String} fieldName Name of the field to test.
* @param {function} testFn The actual test callback.
*
*
* @example
*
*
* test.each([[1,2,3],[2,1,3]])('test', (a, b, c) => enforce(a + b).equals(c));
*/
(fieldName: string | MessageFunc, testFn: TestArgsCB): VestTest[];
Expand Down Expand Up @@ -99,10 +103,10 @@ interface ITest {
memo(fieldName: string, testFn: TestCB, dependencies: any[]): VestTest;
/**
* Create test.each with table of parameters
* @param {any[]} table Array of arrays with params for each run, although it
* @param {any[]} table Array of arrays with params for each run, although it
* will accept 1d-array and treat every item as size one array (e.g. [1,2,3] -> [[1],[2],[3]])
* @example
*
*
* test.each([[1,2,3],[2,1,3]])('test', 'failed', (a, b, c) => enforce(a + b).equals(c));
*/
each(table: any[]): ITestEach;
Expand Down

0 comments on commit d6cce23

Please sign in to comment.