strong-mock
Version:
Type safe mocking library for TypeScript
23 lines (22 loc) • 614 B
TypeScript
import type { TypeMatcher } from './matcher';
/**
* Match an array.
*
* Supports nested matchers.
*
* @param containing If given, the matched array has to contain ALL of these
* elements in ANY order.
*
* @example
* const fn = mock<(arr: number[]) => number>();
* when(() => fn(It.isArray())).thenReturn(1);
* when(() => fn(It.isArray([2, 3]))).thenReturn(2);
*
* fn({ length: 1, 0: 42 }) // throws
* fn([]) === 1
* fn([3, 2, 1]) === 2
*
* @example
* It.isArray([It.isString({ containing: 'foobar' })])
*/
export declare const isArray: <T extends unknown[]>(containing?: T) => TypeMatcher<T>;