forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 3
/
matchers.js
33 lines (30 loc) 路 854 Bytes
/
matchers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
export async function toHaveLengthAsync(
received: any,
lengthPromise: Promise<number>,
) {
const length = await lengthPromise;
const pass = received.length === length;
const message = pass
? () =>
`Expected value to not have length:\n` +
` ${length}\n` +
`Received:\n` +
` ${received}\n` +
`received.length:\n` +
` ${received.length}`
: () =>
`Expected value to have length:\n` +
` ${length}\n` +
`Received:\n` +
` ${received}\n` +
`received.length:\n` +
` ${received.length}`;
return {message, pass};
}