copy jest flow declaration from www
Summary: Copies part of the changes to the flow declarations from www to get the stricter definitions of `it.each`. Reviewed By: jstejada Differential Revision: D17857908 fbshipit-source-id: aafc8e3848d6291a9d527e334ab5d54c5ca635fd
This commit is contained in:
Родитель
cf4d45ec2b
Коммит
a494227d6c
68
flow/jest.js
68
flow/jest.js
|
@ -4,13 +4,16 @@
|
|||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* Copied from https://raw.githubusercontent.com/flow-typed/flow-typed/master/definitions/npm/jest_v23.x.x/flow_v0.39.x-/jest_v23.x.x.js
|
||||
* @flow strict
|
||||
* Modified from https://raw.githubusercontent.com/flow-typed/flow-typed/master/definitions/npm/jest_v23.x.x/flow_v0.39.x-/jest_v23.x.x.js
|
||||
* List of modifications:
|
||||
* - fix some [] -> Array lint warnings
|
||||
* - make it.each/describe.each take $ReadOnlyArray instead of Array<mixed>
|
||||
* - added definition for `isolateModules`
|
||||
*
|
||||
* TODO(T35016336) remove the .each modifications if flow-typed adopts them
|
||||
* @format
|
||||
*/
|
||||
|
||||
/* eslint-disable lint/no-unclear-flowtypes */
|
||||
|
||||
type JestMockFn<TArguments: $ReadOnlyArray<mixed>, TReturn> = {|
|
||||
(...args: TArguments): TReturn,
|
||||
/**
|
||||
|
@ -272,7 +275,7 @@ type JestExtendedMatchersType = {
|
|||
* Use .toBeOneOf when checking if a value is a member of a given Array.
|
||||
* @param {Array.<*>} members
|
||||
*/
|
||||
toBeOneOf(members: any[]): void,
|
||||
toBeOneOf(members: Array<any>): void,
|
||||
|
||||
/**
|
||||
* Use `.toBeNil` when checking a value is `null` or `undefined`.
|
||||
|
@ -300,13 +303,13 @@ type JestExtendedMatchersType = {
|
|||
* Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set.
|
||||
* @param {Array.<*>} members
|
||||
*/
|
||||
toIncludeAllMembers(members: any[]): void,
|
||||
toIncludeAllMembers(members: Array<any>): void,
|
||||
|
||||
/**
|
||||
* Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set.
|
||||
* @param {Array.<*>} members
|
||||
*/
|
||||
toIncludeAnyMembers(members: any[]): void,
|
||||
toIncludeAnyMembers(members: Array<any>): void,
|
||||
|
||||
/**
|
||||
* Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array.
|
||||
|
@ -409,21 +412,21 @@ type JestExtendedMatchersType = {
|
|||
*
|
||||
* @param {Array.<String>} keys
|
||||
*/
|
||||
toContainKeys(keys: string[]): void,
|
||||
toContainKeys(keys: Array<string>): void,
|
||||
|
||||
/**
|
||||
* Use `.toContainAllKeys` when checking if an object only contains all of the provided keys.
|
||||
*
|
||||
* @param {Array.<String>} keys
|
||||
*/
|
||||
toContainAllKeys(keys: string[]): void,
|
||||
toContainAllKeys(keys: Array<string>): void,
|
||||
|
||||
/**
|
||||
* Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys.
|
||||
*
|
||||
* @param {Array.<String>} keys
|
||||
*/
|
||||
toContainAnyKeys(keys: string[]): void,
|
||||
toContainAnyKeys(keys: Array<string>): void,
|
||||
|
||||
/**
|
||||
* Use `.toContainValue` when checking if an object contains the provided value.
|
||||
|
@ -437,21 +440,21 @@ type JestExtendedMatchersType = {
|
|||
*
|
||||
* @param {Array.<*>} values
|
||||
*/
|
||||
toContainValues(values: any[]): void,
|
||||
toContainValues(values: Array<any>): void,
|
||||
|
||||
/**
|
||||
* Use `.toContainAllValues` when checking if an object only contains all of the provided values.
|
||||
*
|
||||
* @param {Array.<*>} values
|
||||
*/
|
||||
toContainAllValues(values: any[]): void,
|
||||
toContainAllValues(values: Array<any>): void,
|
||||
|
||||
/**
|
||||
* Use `.toContainAnyValues` when checking if an object contains at least one of the provided values.
|
||||
*
|
||||
* @param {Array.<*>} values
|
||||
*/
|
||||
toContainAnyValues(values: any[]): void,
|
||||
toContainAnyValues(values: Array<any>): void,
|
||||
|
||||
/**
|
||||
* Use `.toContainEntry` when checking if an object contains the provided entry.
|
||||
|
@ -465,21 +468,21 @@ type JestExtendedMatchersType = {
|
|||
*
|
||||
* @param {Array.<Array.<String, String>>} entries
|
||||
*/
|
||||
toContainEntries(entries: [string, string][]): void,
|
||||
toContainEntries(entries: Array<[string, string]>): void,
|
||||
|
||||
/**
|
||||
* Use `.toContainAllEntries` when checking if an object only contains all of the provided entries.
|
||||
*
|
||||
* @param {Array.<Array.<String, String>>} entries
|
||||
*/
|
||||
toContainAllEntries(entries: [string, string][]): void,
|
||||
toContainAllEntries(entries: Array<[string, string]>): void,
|
||||
|
||||
/**
|
||||
* Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries.
|
||||
*
|
||||
* @param {Array.<Array.<String, String>>} entries
|
||||
*/
|
||||
toContainAnyEntries(entries: [string, string][]): void,
|
||||
toContainAnyEntries(entries: Array<[string, string]>): void,
|
||||
|
||||
/**
|
||||
* Use `.toBeExtensible` when checking if an object is extensible.
|
||||
|
@ -542,7 +545,7 @@ type JestExtendedMatchersType = {
|
|||
*
|
||||
* @param {Array.<String>} substring
|
||||
*/
|
||||
toIncludeMultiple(substring: string[]): void,
|
||||
toIncludeMultiple(substring: Array<string>): void,
|
||||
};
|
||||
|
||||
interface JestExpectType {
|
||||
|
@ -824,7 +827,7 @@ type JestObjectType = {
|
|||
* Returns the actual module instead of a mock, bypassing all checks on
|
||||
* whether the module should receive a mock implementation or not.
|
||||
*/
|
||||
requireActual(moduleName: string): any,
|
||||
requireActual<T>(m: $Flow$ModuleRef<T> | string): T,
|
||||
/**
|
||||
* Returns a mock module instead of the actual module, bypassing all checks
|
||||
* on whether the module should be required normally or not.
|
||||
|
@ -952,11 +955,11 @@ declare var describe: {
|
|||
*
|
||||
* @param {table} table of Test
|
||||
*/
|
||||
each(
|
||||
table: $ReadOnlyArray<mixed | $ReadOnlyArray<mixed>>,
|
||||
each<TArguments: Array<mixed> | mixed>(
|
||||
table: $ReadOnlyArray<TArguments>,
|
||||
): (
|
||||
name: JestTestName,
|
||||
fn?: (...args: Array<any>) => ?Promise<mixed>,
|
||||
fn?: (...args: TArguments) => ?Promise<mixed>,
|
||||
) => void,
|
||||
};
|
||||
|
||||
|
@ -979,11 +982,11 @@ declare var it: {
|
|||
*
|
||||
* @param {table} table of Test
|
||||
*/
|
||||
each(
|
||||
table: $ReadOnlyArray<mixed | $ReadOnlyArray<mixed>>,
|
||||
each<TArguments: Array<mixed> | mixed>(
|
||||
table: $ReadOnlyArray<TArguments>,
|
||||
): (
|
||||
name: JestTestName,
|
||||
fn?: (...args: Array<any>) => ?Promise<mixed>,
|
||||
fn?: (...args: TArguments) => ?Promise<mixed>,
|
||||
) => void,
|
||||
/**
|
||||
* Only run this test
|
||||
|
@ -997,11 +1000,11 @@ declare var it: {
|
|||
fn?: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number,
|
||||
): {
|
||||
each(
|
||||
table: $ReadOnlyArray<mixed | $ReadOnlyArray<mixed>>,
|
||||
each<TArguments: Array<mixed> | mixed>(
|
||||
table: $ReadOnlyArray<TArguments>,
|
||||
): (
|
||||
name: JestTestName,
|
||||
fn?: (...args: Array<any>) => ?Promise<mixed>,
|
||||
fn?: (...args: TArguments) => ?Promise<mixed>,
|
||||
) => void,
|
||||
},
|
||||
/**
|
||||
|
@ -1028,17 +1031,6 @@ declare var it: {
|
|||
fn?: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number,
|
||||
): void,
|
||||
/**
|
||||
* each runs this test against array of argument arrays per each run
|
||||
*
|
||||
* @param {table} table of Test
|
||||
*/
|
||||
each(
|
||||
table: $ReadOnlyArray<mixed | $ReadOnlyArray<mixed>>,
|
||||
): (
|
||||
name: JestTestName,
|
||||
fn?: (...args: Array<any>) => ?Promise<mixed>,
|
||||
) => void,
|
||||
};
|
||||
declare function fit(
|
||||
name: JestTestName,
|
||||
|
|
Загрузка…
Ссылка в новой задаче