Change endpoint from persons to people

This commit is contained in:
xfarrow
2025-03-23 21:00:08 +01:00
parent 4ae263662c
commit d005193f63
7158 changed files with 700476 additions and 735 deletions

21
backend/apis/nodejs/node_modules/expect/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) Meta Platforms, Inc. and affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

3
backend/apis/nodejs/node_modules/expect/README.md generated vendored Normal file
View File

@ -0,0 +1,3 @@
# expect
This package exports the `expect` function used in [Jest](https://jestjs.io/). You can find its documentation [on Jest's website](https://jestjs.io/docs/expect).

View File

@ -0,0 +1,375 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.closeTo =
exports.arrayNotContaining =
exports.arrayContaining =
exports.anything =
exports.any =
exports.AsymmetricMatcher =
void 0;
exports.hasProperty = hasProperty;
exports.stringNotMatching =
exports.stringNotContaining =
exports.stringMatching =
exports.stringContaining =
exports.objectNotContaining =
exports.objectContaining =
exports.notCloseTo =
void 0;
var _expectUtils = require('@jest/expect-utils');
var matcherUtils = _interopRequireWildcard(require('jest-matcher-utils'));
var _jestUtil = require('jest-util');
var _jestMatchersObject = require('./jestMatchersObject');
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== 'function') return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function (nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interopRequireWildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return {default: obj};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor =
Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
const functionToString = Function.prototype.toString;
function fnNameFor(func) {
if (func.name) {
return func.name;
}
const matches = functionToString
.call(func)
.match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/);
return matches ? matches[1] : '<anonymous>';
}
const utils = Object.freeze({
...matcherUtils,
iterableEquality: _expectUtils.iterableEquality,
subsetEquality: _expectUtils.subsetEquality
});
function getPrototype(obj) {
if (Object.getPrototypeOf) {
return Object.getPrototypeOf(obj);
}
if (obj.constructor.prototype == obj) {
return null;
}
return obj.constructor.prototype;
}
function hasProperty(obj, property) {
if (!obj) {
return false;
}
if (Object.prototype.hasOwnProperty.call(obj, property)) {
return true;
}
return hasProperty(getPrototype(obj), property);
}
class AsymmetricMatcher {
$$typeof = Symbol.for('jest.asymmetricMatcher');
constructor(sample, inverse = false) {
this.sample = sample;
this.inverse = inverse;
}
getMatcherContext() {
return {
customTesters: (0, _jestMatchersObject.getCustomEqualityTesters)(),
// eslint-disable-next-line @typescript-eslint/no-empty-function
dontThrow: () => {},
...(0, _jestMatchersObject.getState)(),
equals: _expectUtils.equals,
isNot: this.inverse,
utils
};
}
}
exports.AsymmetricMatcher = AsymmetricMatcher;
class Any extends AsymmetricMatcher {
constructor(sample) {
if (typeof sample === 'undefined') {
throw new TypeError(
'any() expects to be passed a constructor function. ' +
'Please pass one or use anything() to match any object.'
);
}
super(sample);
}
asymmetricMatch(other) {
if (this.sample == String) {
return typeof other == 'string' || other instanceof String;
}
if (this.sample == Number) {
return typeof other == 'number' || other instanceof Number;
}
if (this.sample == Function) {
return typeof other == 'function' || other instanceof Function;
}
if (this.sample == Boolean) {
return typeof other == 'boolean' || other instanceof Boolean;
}
if (this.sample == BigInt) {
return typeof other == 'bigint' || other instanceof BigInt;
}
if (this.sample == Symbol) {
return typeof other == 'symbol' || other instanceof Symbol;
}
if (this.sample == Object) {
return typeof other == 'object';
}
return other instanceof this.sample;
}
toString() {
return 'Any';
}
getExpectedType() {
if (this.sample == String) {
return 'string';
}
if (this.sample == Number) {
return 'number';
}
if (this.sample == Function) {
return 'function';
}
if (this.sample == Object) {
return 'object';
}
if (this.sample == Boolean) {
return 'boolean';
}
return fnNameFor(this.sample);
}
toAsymmetricMatcher() {
return `Any<${fnNameFor(this.sample)}>`;
}
}
class Anything extends AsymmetricMatcher {
asymmetricMatch(other) {
return other != null;
}
toString() {
return 'Anything';
}
// No getExpectedType method, because it matches either null or undefined.
toAsymmetricMatcher() {
return 'Anything';
}
}
class ArrayContaining extends AsymmetricMatcher {
constructor(sample, inverse = false) {
super(sample, inverse);
}
asymmetricMatch(other) {
if (!Array.isArray(this.sample)) {
throw new Error(
`You must provide an array to ${this.toString()}, not '${typeof this
.sample}'.`
);
}
const matcherContext = this.getMatcherContext();
const result =
this.sample.length === 0 ||
(Array.isArray(other) &&
this.sample.every(item =>
other.some(another =>
(0, _expectUtils.equals)(
item,
another,
matcherContext.customTesters
)
)
));
return this.inverse ? !result : result;
}
toString() {
return `Array${this.inverse ? 'Not' : ''}Containing`;
}
getExpectedType() {
return 'array';
}
}
class ObjectContaining extends AsymmetricMatcher {
constructor(sample, inverse = false) {
super(sample, inverse);
}
asymmetricMatch(other) {
if (typeof this.sample !== 'object') {
throw new Error(
`You must provide an object to ${this.toString()}, not '${typeof this
.sample}'.`
);
}
let result = true;
const matcherContext = this.getMatcherContext();
const objectKeys = (0, _expectUtils.getObjectKeys)(this.sample);
for (const key of objectKeys) {
if (
!hasProperty(other, key) ||
!(0, _expectUtils.equals)(
this.sample[key],
other[key],
matcherContext.customTesters
)
) {
result = false;
break;
}
}
return this.inverse ? !result : result;
}
toString() {
return `Object${this.inverse ? 'Not' : ''}Containing`;
}
getExpectedType() {
return 'object';
}
}
class StringContaining extends AsymmetricMatcher {
constructor(sample, inverse = false) {
if (!(0, _expectUtils.isA)('String', sample)) {
throw new Error('Expected is not a string');
}
super(sample, inverse);
}
asymmetricMatch(other) {
const result =
(0, _expectUtils.isA)('String', other) && other.includes(this.sample);
return this.inverse ? !result : result;
}
toString() {
return `String${this.inverse ? 'Not' : ''}Containing`;
}
getExpectedType() {
return 'string';
}
}
class StringMatching extends AsymmetricMatcher {
constructor(sample, inverse = false) {
if (
!(0, _expectUtils.isA)('String', sample) &&
!(0, _expectUtils.isA)('RegExp', sample)
) {
throw new Error('Expected is not a String or a RegExp');
}
super(new RegExp(sample), inverse);
}
asymmetricMatch(other) {
const result =
(0, _expectUtils.isA)('String', other) && this.sample.test(other);
return this.inverse ? !result : result;
}
toString() {
return `String${this.inverse ? 'Not' : ''}Matching`;
}
getExpectedType() {
return 'string';
}
}
class CloseTo extends AsymmetricMatcher {
precision;
constructor(sample, precision = 2, inverse = false) {
if (!(0, _expectUtils.isA)('Number', sample)) {
throw new Error('Expected is not a Number');
}
if (!(0, _expectUtils.isA)('Number', precision)) {
throw new Error('Precision is not a Number');
}
super(sample);
this.inverse = inverse;
this.precision = precision;
}
asymmetricMatch(other) {
if (!(0, _expectUtils.isA)('Number', other)) {
return false;
}
let result = false;
if (other === Infinity && this.sample === Infinity) {
result = true; // Infinity - Infinity is NaN
} else if (other === -Infinity && this.sample === -Infinity) {
result = true; // -Infinity - -Infinity is NaN
} else {
result =
Math.abs(this.sample - other) < Math.pow(10, -this.precision) / 2;
}
return this.inverse ? !result : result;
}
toString() {
return `Number${this.inverse ? 'Not' : ''}CloseTo`;
}
getExpectedType() {
return 'number';
}
toAsymmetricMatcher() {
return [
this.toString(),
this.sample,
`(${(0, _jestUtil.pluralize)('digit', this.precision)})`
].join(' ');
}
}
const any = expectedObject => new Any(expectedObject);
exports.any = any;
const anything = () => new Anything();
exports.anything = anything;
const arrayContaining = sample => new ArrayContaining(sample);
exports.arrayContaining = arrayContaining;
const arrayNotContaining = sample => new ArrayContaining(sample, true);
exports.arrayNotContaining = arrayNotContaining;
const objectContaining = sample => new ObjectContaining(sample);
exports.objectContaining = objectContaining;
const objectNotContaining = sample => new ObjectContaining(sample, true);
exports.objectNotContaining = objectNotContaining;
const stringContaining = expected => new StringContaining(expected);
exports.stringContaining = stringContaining;
const stringNotContaining = expected => new StringContaining(expected, true);
exports.stringNotContaining = stringNotContaining;
const stringMatching = expected => new StringMatching(expected);
exports.stringMatching = stringMatching;
const stringNotMatching = expected => new StringMatching(expected, true);
exports.stringNotMatching = stringNotMatching;
const closeTo = (expected, precision) => new CloseTo(expected, precision);
exports.closeTo = closeTo;
const notCloseTo = (expected, precision) =>
new CloseTo(expected, precision, true);
exports.notCloseTo = notCloseTo;

View File

@ -0,0 +1,86 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _jestMatcherUtils = require('jest-matcher-utils');
var _jestMatchersObject = require('./jestMatchersObject');
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
const resetAssertionsLocalState = () => {
(0, _jestMatchersObject.setState)({
assertionCalls: 0,
expectedAssertionsNumber: null,
isExpectingAssertions: false,
numPassingAsserts: 0
});
};
// Create and format all errors related to the mismatched number of `expect`
// calls and reset the matcher's state.
const extractExpectedAssertionsErrors = () => {
const result = [];
const {
assertionCalls,
expectedAssertionsNumber,
expectedAssertionsNumberError,
isExpectingAssertions,
isExpectingAssertionsError
} = (0, _jestMatchersObject.getState)();
resetAssertionsLocalState();
if (
typeof expectedAssertionsNumber === 'number' &&
assertionCalls !== expectedAssertionsNumber
) {
const numOfAssertionsExpected = (0, _jestMatcherUtils.EXPECTED_COLOR)(
(0, _jestMatcherUtils.pluralize)('assertion', expectedAssertionsNumber)
);
expectedAssertionsNumberError.message =
`${(0, _jestMatcherUtils.matcherHint)(
'.assertions',
'',
expectedAssertionsNumber.toString(),
{
isDirectExpectCall: true
}
)}\n\n` +
`Expected ${numOfAssertionsExpected} to be called but received ${(0,
_jestMatcherUtils.RECEIVED_COLOR)(
(0, _jestMatcherUtils.pluralize)('assertion call', assertionCalls || 0)
)}.`;
result.push({
actual: assertionCalls.toString(),
error: expectedAssertionsNumberError,
expected: expectedAssertionsNumber.toString()
});
}
if (isExpectingAssertions && assertionCalls === 0) {
const expected = (0, _jestMatcherUtils.EXPECTED_COLOR)(
'at least one assertion'
);
const received = (0, _jestMatcherUtils.RECEIVED_COLOR)('received none');
isExpectingAssertionsError.message = `${(0, _jestMatcherUtils.matcherHint)(
'.hasAssertions',
'',
'',
{
isDirectExpectCall: true
}
)}\n\nExpected ${expected} to be called but ${received}.`;
result.push({
actual: 'none',
error: isExpectingAssertionsError,
expected: 'at least one'
});
}
return result;
};
var _default = extractExpectedAssertionsErrors;
exports.default = _default;

View File

@ -0,0 +1,370 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {EqualsFunction} from '@jest/expect-utils';
import type * as jestMatcherUtils from 'jest-matcher-utils';
import {Tester} from '@jest/expect-utils';
import {TesterContext} from '@jest/expect-utils';
export declare abstract class AsymmetricMatcher<T>
implements AsymmetricMatcher_2
{
protected sample: T;
protected inverse: boolean;
$$typeof: symbol;
constructor(sample: T, inverse?: boolean);
protected getMatcherContext(): MatcherContext;
abstract asymmetricMatch(other: unknown): boolean;
abstract toString(): string;
getExpectedType?(): string;
toAsymmetricMatcher?(): string;
}
declare type AsymmetricMatcher_2 = {
asymmetricMatch(other: unknown): boolean;
toString(): string;
getExpectedType?(): string;
toAsymmetricMatcher?(): string;
};
export declare interface AsymmetricMatchers {
any(sample: unknown): AsymmetricMatcher_2;
anything(): AsymmetricMatcher_2;
arrayContaining(sample: Array<unknown>): AsymmetricMatcher_2;
closeTo(sample: number, precision?: number): AsymmetricMatcher_2;
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher_2;
stringContaining(sample: string): AsymmetricMatcher_2;
stringMatching(sample: string | RegExp): AsymmetricMatcher_2;
}
export declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
export declare interface BaseExpect {
assertions(numberOfAssertions: number): void;
addEqualityTesters(testers: Array<Tester>): void;
extend(matchers: MatchersObject): void;
extractExpectedAssertionsErrors(): ExpectedAssertionsErrors;
getState(): MatcherState;
hasAssertions(): void;
setState(state: Partial<MatcherState>): void;
}
export declare type Expect = {
<T = unknown>(actual: T): Matchers<void, T> &
Inverse<Matchers<void, T>> &
PromiseMatchers<T>;
} & BaseExpect &
AsymmetricMatchers &
Inverse<Omit<AsymmetricMatchers, 'any' | 'anything'>>;
declare const expect: Expect;
export default expect;
export {expect};
export declare type ExpectationResult =
| SyncExpectationResult
| AsyncExpectationResult;
declare type ExpectedAssertionsErrors = Array<{
actual: string | number;
error: Error;
expected: string;
}>;
declare type Inverse<Matchers> = {
/**
* Inverse next matcher. If you know how to test something, `.not` lets you test its opposite.
*/
not: Matchers;
};
export declare class JestAssertionError extends Error {
matcherResult?: Omit<SyncExpectationResult, 'message'> & {
message: string;
};
}
export declare type MatcherContext = MatcherUtils & Readonly<MatcherState>;
export declare type MatcherFunction<Expected extends Array<unknown> = []> =
MatcherFunctionWithContext<MatcherContext, Expected>;
export declare type MatcherFunctionWithContext<
Context extends MatcherContext = MatcherContext,
Expected extends Array<any> = [] /** TODO should be: extends Array<unknown> = [] */,
> = (
this: Context,
actual: unknown,
...expected: Expected
) => ExpectationResult;
export declare interface Matchers<R extends void | Promise<void>, T = unknown> {
/**
* Ensures the last call to a mock function was provided specific args.
*/
lastCalledWith(...expected: Array<unknown>): R;
/**
* Ensure that the last call to a mock function has returned a specified value.
*/
lastReturnedWith(expected?: unknown): R;
/**
* Ensure that a mock function is called with specific arguments on an Nth call.
*/
nthCalledWith(nth: number, ...expected: Array<unknown>): R;
/**
* Ensure that the nth call to a mock function has returned a specified value.
*/
nthReturnedWith(nth: number, expected?: unknown): R;
/**
* Checks that a value is what you expect. It calls `Object.is` to compare values.
* Don't use `toBe` with floating-point numbers.
*/
toBe(expected: unknown): R;
/**
* Ensures that a mock function is called.
*/
toBeCalled(): R;
/**
* Ensures that a mock function is called an exact number of times.
*/
toBeCalledTimes(expected: number): R;
/**
* Ensure that a mock function is called with specific arguments.
*/
toBeCalledWith(...expected: Array<unknown>): R;
/**
* Using exact equality with floating point numbers is a bad idea.
* Rounding means that intuitive things fail.
* The default for `precision` is 2.
*/
toBeCloseTo(expected: number, precision?: number): R;
/**
* Ensure that a variable is not undefined.
*/
toBeDefined(): R;
/**
* When you don't care what a value is, you just want to
* ensure a value is false in a boolean context.
*/
toBeFalsy(): R;
/**
* For comparing floating point numbers.
*/
toBeGreaterThan(expected: number | bigint): R;
/**
* For comparing floating point numbers.
*/
toBeGreaterThanOrEqual(expected: number | bigint): R;
/**
* Ensure that an object is an instance of a class.
* This matcher uses `instanceof` underneath.
*/
toBeInstanceOf(expected: unknown): R;
/**
* For comparing floating point numbers.
*/
toBeLessThan(expected: number | bigint): R;
/**
* For comparing floating point numbers.
*/
toBeLessThanOrEqual(expected: number | bigint): R;
/**
* Used to check that a variable is NaN.
*/
toBeNaN(): R;
/**
* This is the same as `.toBe(null)` but the error messages are a bit nicer.
* So use `.toBeNull()` when you want to check that something is null.
*/
toBeNull(): R;
/**
* Use when you don't care what a value is, you just want to ensure a value
* is true in a boolean context. In JavaScript, there are six falsy values:
* `false`, `0`, `''`, `null`, `undefined`, and `NaN`. Everything else is truthy.
*/
toBeTruthy(): R;
/**
* Used to check that a variable is undefined.
*/
toBeUndefined(): R;
/**
* Used when you want to check that an item is in a list.
* For testing the items in the list, this uses `===`, a strict equality check.
*/
toContain(expected: unknown): R;
/**
* Used when you want to check that an item is in a list.
* For testing the items in the list, this matcher recursively checks the
* equality of all fields, rather than checking for object identity.
*/
toContainEqual(expected: unknown): R;
/**
* Used when you want to check that two objects have the same value.
* This matcher recursively checks the equality of all fields, rather than checking for object identity.
*/
toEqual(expected: unknown): R;
/**
* Ensures that a mock function is called.
*/
toHaveBeenCalled(): R;
/**
* Ensures that a mock function is called an exact number of times.
*/
toHaveBeenCalledTimes(expected: number): R;
/**
* Ensure that a mock function is called with specific arguments.
*/
toHaveBeenCalledWith(...expected: Array<unknown>): R;
/**
* Ensure that a mock function is called with specific arguments on an Nth call.
*/
toHaveBeenNthCalledWith(nth: number, ...expected: Array<unknown>): R;
/**
* If you have a mock function, you can use `.toHaveBeenLastCalledWith`
* to test what arguments it was last called with.
*/
toHaveBeenLastCalledWith(...expected: Array<unknown>): R;
/**
* Use to test the specific value that a mock function last returned.
* If the last call to the mock function threw an error, then this matcher will fail
* no matter what value you provided as the expected return value.
*/
toHaveLastReturnedWith(expected?: unknown): R;
/**
* Used to check that an object has a `.length` property
* and it is set to a certain numeric value.
*/
toHaveLength(expected: number): R;
/**
* Use to test the specific value that a mock function returned for the nth call.
* If the nth call to the mock function threw an error, then this matcher will fail
* no matter what value you provided as the expected return value.
*/
toHaveNthReturnedWith(nth: number, expected?: unknown): R;
/**
* Use to check if property at provided reference keyPath exists for an object.
* For checking deeply nested properties in an object you may use dot notation or an array containing
* the keyPath for deep references.
*
* Optionally, you can provide a value to check if it's equal to the value present at keyPath
* on the target object. This matcher uses 'deep equality' (like `toEqual()`) and recursively checks
* the equality of all fields.
*
* @example
*
* expect(houseForSale).toHaveProperty('kitchen.area', 20);
*/
toHaveProperty(
expectedPath: string | Array<string>,
expectedValue?: unknown,
): R;
/**
* Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time
*/
toHaveReturned(): R;
/**
* Use to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times.
* Any calls to the mock function that throw an error are not counted toward the number of times the function returned.
*/
toHaveReturnedTimes(expected: number): R;
/**
* Use to ensure that a mock function returned a specific value.
*/
toHaveReturnedWith(expected?: unknown): R;
/**
* Check that a string matches a regular expression.
*/
toMatch(expected: string | RegExp): R;
/**
* Used to check that a JavaScript object matches a subset of the properties of an object
*/
toMatchObject(
expected: Record<string, unknown> | Array<Record<string, unknown>>,
): R;
/**
* Ensure that a mock function has returned (as opposed to thrown) at least once.
*/
toReturn(): R;
/**
* Ensure that a mock function has returned (as opposed to thrown) a specified number of times.
*/
toReturnTimes(expected: number): R;
/**
* Ensure that a mock function has returned a specified value at least once.
*/
toReturnWith(expected?: unknown): R;
/**
* Use to test that objects have the same types as well as structure.
*/
toStrictEqual(expected: unknown): R;
/**
* Used to test that a function throws when it is called.
*/
toThrow(expected?: unknown): R;
/**
* If you want to test that a specific error is thrown inside a function.
*/
toThrowError(expected?: unknown): R;
}
declare type MatchersObject = {
[name: string]: RawMatcherFn;
};
export declare interface MatcherState {
assertionCalls: number;
currentConcurrentTestName?: () => string | undefined;
currentTestName?: string;
error?: Error;
expand?: boolean;
expectedAssertionsNumber: number | null;
expectedAssertionsNumberError?: Error;
isExpectingAssertions: boolean;
isExpectingAssertionsError?: Error;
isNot?: boolean;
numPassingAsserts: number;
promise?: string;
suppressedErrors: Array<Error>;
testPath?: string;
}
export declare interface MatcherUtils {
customTesters: Array<Tester>;
dontThrow(): void;
equals: EqualsFunction;
utils: typeof jestMatcherUtils & {
iterableEquality: Tester;
subsetEquality: Tester;
};
}
declare type PromiseMatchers<T = unknown> = {
/**
* Unwraps the reason of a rejected promise so any other matcher can be chained.
* If the promise is fulfilled the assertion fails.
*/
rejects: Matchers<Promise<void>, T> & Inverse<Matchers<Promise<void>, T>>;
/**
* Unwraps the value of a fulfilled promise so any other matcher can be chained.
* If the promise is rejected the assertion fails.
*/
resolves: Matchers<Promise<void>, T> & Inverse<Matchers<Promise<void>, T>>;
};
declare type RawMatcherFn<Context extends MatcherContext = MatcherContext> = {
(this: Context, actual: any, ...expected: Array<any>): ExpectationResult;
};
export declare type SyncExpectationResult = {
pass: boolean;
message(): string;
};
export {Tester};
export {TesterContext};
export {};

410
backend/apis/nodejs/node_modules/expect/build/index.js generated vendored Normal file
View File

@ -0,0 +1,410 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
Object.defineProperty(exports, 'AsymmetricMatcher', {
enumerable: true,
get: function () {
return _asymmetricMatchers.AsymmetricMatcher;
}
});
exports.expect = exports.default = exports.JestAssertionError = void 0;
var _expectUtils = require('@jest/expect-utils');
var matcherUtils = _interopRequireWildcard(require('jest-matcher-utils'));
var _jestUtil = require('jest-util');
var _asymmetricMatchers = require('./asymmetricMatchers');
var _extractExpectedAssertionsErrors = _interopRequireDefault(
require('./extractExpectedAssertionsErrors')
);
var _jestMatchersObject = require('./jestMatchersObject');
var _matchers = _interopRequireDefault(require('./matchers'));
var _spyMatchers = _interopRequireDefault(require('./spyMatchers'));
var _toThrowMatchers = _interopRequireWildcard(require('./toThrowMatchers'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== 'function') return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function (nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interopRequireWildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return {default: obj};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor =
Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
var Promise =
globalThis[Symbol.for('jest-native-promise')] || globalThis.Promise;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
/* eslint-disable local/prefer-spread-eventually */
class JestAssertionError extends Error {
matcherResult;
}
exports.JestAssertionError = JestAssertionError;
const createToThrowErrorMatchingSnapshotMatcher = function (matcher) {
return function (received, testNameOrInlineSnapshot) {
return matcher.apply(this, [received, testNameOrInlineSnapshot, true]);
};
};
const getPromiseMatcher = (name, matcher) => {
if (name === 'toThrow' || name === 'toThrowError') {
return (0, _toThrowMatchers.createMatcher)(name, true);
} else if (
name === 'toThrowErrorMatchingSnapshot' ||
name === 'toThrowErrorMatchingInlineSnapshot'
) {
return createToThrowErrorMatchingSnapshotMatcher(matcher);
}
return null;
};
const expect = (actual, ...rest) => {
if (rest.length !== 0) {
throw new Error('Expect takes at most one argument.');
}
const allMatchers = (0, _jestMatchersObject.getMatchers)();
const expectation = {
not: {},
rejects: {
not: {}
},
resolves: {
not: {}
}
};
const err = new JestAssertionError();
Object.keys(allMatchers).forEach(name => {
const matcher = allMatchers[name];
const promiseMatcher = getPromiseMatcher(name, matcher) || matcher;
expectation[name] = makeThrowingMatcher(matcher, false, '', actual);
expectation.not[name] = makeThrowingMatcher(matcher, true, '', actual);
expectation.resolves[name] = makeResolveMatcher(
name,
promiseMatcher,
false,
actual,
err
);
expectation.resolves.not[name] = makeResolveMatcher(
name,
promiseMatcher,
true,
actual,
err
);
expectation.rejects[name] = makeRejectMatcher(
name,
promiseMatcher,
false,
actual,
err
);
expectation.rejects.not[name] = makeRejectMatcher(
name,
promiseMatcher,
true,
actual,
err
);
});
return expectation;
};
exports.expect = expect;
const getMessage = message =>
(message && message()) ||
matcherUtils.RECEIVED_COLOR('No message was specified for this matcher.');
const makeResolveMatcher =
(matcherName, matcher, isNot, actual, outerErr) =>
(...args) => {
const options = {
isNot,
promise: 'resolves'
};
if (!(0, _jestUtil.isPromise)(actual)) {
throw new JestAssertionError(
matcherUtils.matcherErrorMessage(
matcherUtils.matcherHint(matcherName, undefined, '', options),
`${matcherUtils.RECEIVED_COLOR('received')} value must be a promise`,
matcherUtils.printWithType(
'Received',
actual,
matcherUtils.printReceived
)
)
);
}
const innerErr = new JestAssertionError();
return actual.then(
result =>
makeThrowingMatcher(matcher, isNot, 'resolves', result, innerErr).apply(
null,
args
),
reason => {
outerErr.message =
`${matcherUtils.matcherHint(
matcherName,
undefined,
'',
options
)}\n\n` +
'Received promise rejected instead of resolved\n' +
`Rejected to value: ${matcherUtils.printReceived(reason)}`;
return Promise.reject(outerErr);
}
);
};
const makeRejectMatcher =
(matcherName, matcher, isNot, actual, outerErr) =>
(...args) => {
const options = {
isNot,
promise: 'rejects'
};
const actualWrapper = typeof actual === 'function' ? actual() : actual;
if (!(0, _jestUtil.isPromise)(actualWrapper)) {
throw new JestAssertionError(
matcherUtils.matcherErrorMessage(
matcherUtils.matcherHint(matcherName, undefined, '', options),
`${matcherUtils.RECEIVED_COLOR(
'received'
)} value must be a promise or a function returning a promise`,
matcherUtils.printWithType(
'Received',
actual,
matcherUtils.printReceived
)
)
);
}
const innerErr = new JestAssertionError();
return actualWrapper.then(
result => {
outerErr.message =
`${matcherUtils.matcherHint(
matcherName,
undefined,
'',
options
)}\n\n` +
'Received promise resolved instead of rejected\n' +
`Resolved to value: ${matcherUtils.printReceived(result)}`;
return Promise.reject(outerErr);
},
reason =>
makeThrowingMatcher(matcher, isNot, 'rejects', reason, innerErr).apply(
null,
args
)
);
};
const makeThrowingMatcher = (matcher, isNot, promise, actual, err) =>
function throwingMatcher(...args) {
let throws = true;
const utils = {
...matcherUtils,
iterableEquality: _expectUtils.iterableEquality,
subsetEquality: _expectUtils.subsetEquality
};
const matcherUtilsThing = {
customTesters: (0, _jestMatchersObject.getCustomEqualityTesters)(),
// When throws is disabled, the matcher will not throw errors during test
// execution but instead add them to the global matcher state. If a
// matcher throws, test execution is normally stopped immediately. The
// snapshot matcher uses it because we want to log all snapshot
// failures in a test.
dontThrow: () => (throws = false),
equals: _expectUtils.equals,
utils
};
const matcherContext = {
...(0, _jestMatchersObject.getState)(),
...matcherUtilsThing,
error: err,
isNot,
promise
};
const processResult = (result, asyncError) => {
_validateResult(result);
(0, _jestMatchersObject.getState)().assertionCalls++;
if ((result.pass && isNot) || (!result.pass && !isNot)) {
// XOR
const message = getMessage(result.message);
let error;
if (err) {
error = err;
error.message = message;
} else if (asyncError) {
error = asyncError;
error.message = message;
} else {
error = new JestAssertionError(message);
// Try to remove this function from the stack trace frame.
// Guard for some environments (browsers) that do not support this feature.
if (Error.captureStackTrace) {
Error.captureStackTrace(error, throwingMatcher);
}
}
// Passing the result of the matcher with the error so that a custom
// reporter could access the actual and expected objects of the result
// for example in order to display a custom visual diff
error.matcherResult = {
...result,
message
};
if (throws) {
throw error;
} else {
(0, _jestMatchersObject.getState)().suppressedErrors.push(error);
}
} else {
(0, _jestMatchersObject.getState)().numPassingAsserts++;
}
};
const handleError = error => {
if (
matcher[_jestMatchersObject.INTERNAL_MATCHER_FLAG] === true &&
!(error instanceof JestAssertionError) &&
error.name !== 'PrettyFormatPluginError' &&
// Guard for some environments (browsers) that do not support this feature.
Error.captureStackTrace
) {
// Try to remove this and deeper functions from the stack trace frame.
Error.captureStackTrace(error, throwingMatcher);
}
throw error;
};
let potentialResult;
try {
potentialResult =
matcher[_jestMatchersObject.INTERNAL_MATCHER_FLAG] === true
? matcher.call(matcherContext, actual, ...args)
: // It's a trap specifically for inline snapshot to capture this name
// in the stack trace, so that it can correctly get the custom matcher
// function call.
(function __EXTERNAL_MATCHER_TRAP__() {
return matcher.call(matcherContext, actual, ...args);
})();
if ((0, _jestUtil.isPromise)(potentialResult)) {
const asyncError = new JestAssertionError();
if (Error.captureStackTrace) {
Error.captureStackTrace(asyncError, throwingMatcher);
}
return potentialResult
.then(aResult => processResult(aResult, asyncError))
.catch(handleError);
} else {
return processResult(potentialResult);
}
} catch (error) {
return handleError(error);
}
};
expect.extend = matchers =>
(0, _jestMatchersObject.setMatchers)(matchers, false, expect);
expect.addEqualityTesters = customTesters =>
(0, _jestMatchersObject.addCustomEqualityTesters)(customTesters);
expect.anything = _asymmetricMatchers.anything;
expect.any = _asymmetricMatchers.any;
expect.not = {
arrayContaining: _asymmetricMatchers.arrayNotContaining,
closeTo: _asymmetricMatchers.notCloseTo,
objectContaining: _asymmetricMatchers.objectNotContaining,
stringContaining: _asymmetricMatchers.stringNotContaining,
stringMatching: _asymmetricMatchers.stringNotMatching
};
expect.arrayContaining = _asymmetricMatchers.arrayContaining;
expect.closeTo = _asymmetricMatchers.closeTo;
expect.objectContaining = _asymmetricMatchers.objectContaining;
expect.stringContaining = _asymmetricMatchers.stringContaining;
expect.stringMatching = _asymmetricMatchers.stringMatching;
const _validateResult = result => {
if (
typeof result !== 'object' ||
typeof result.pass !== 'boolean' ||
(result.message &&
typeof result.message !== 'string' &&
typeof result.message !== 'function')
) {
throw new Error(
'Unexpected return from a matcher function.\n' +
'Matcher functions should ' +
'return an object in the following format:\n' +
' {message?: string | function, pass: boolean}\n' +
`'${matcherUtils.stringify(result)}' was returned`
);
}
};
function assertions(expected) {
const error = new Error();
if (Error.captureStackTrace) {
Error.captureStackTrace(error, assertions);
}
(0, _jestMatchersObject.setState)({
expectedAssertionsNumber: expected,
expectedAssertionsNumberError: error
});
}
function hasAssertions(...args) {
const error = new Error();
if (Error.captureStackTrace) {
Error.captureStackTrace(error, hasAssertions);
}
matcherUtils.ensureNoExpected(args[0], '.hasAssertions');
(0, _jestMatchersObject.setState)({
isExpectingAssertions: true,
isExpectingAssertionsError: error
});
}
// add default jest matchers
(0, _jestMatchersObject.setMatchers)(_matchers.default, true, expect);
(0, _jestMatchersObject.setMatchers)(_spyMatchers.default, true, expect);
(0, _jestMatchersObject.setMatchers)(_toThrowMatchers.default, true, expect);
expect.assertions = assertions;
expect.hasAssertions = hasAssertions;
expect.getState = _jestMatchersObject.getState;
expect.setState = _jestMatchersObject.setState;
expect.extractExpectedAssertionsErrors =
_extractExpectedAssertionsErrors.default;
var _default = expect;
exports.default = _default;

View File

@ -0,0 +1,123 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.setState =
exports.setMatchers =
exports.getState =
exports.getMatchers =
exports.getCustomEqualityTesters =
exports.addCustomEqualityTesters =
exports.INTERNAL_MATCHER_FLAG =
void 0;
var _jestGetType = require('jest-get-type');
var _asymmetricMatchers = require('./asymmetricMatchers');
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
// Global matchers object holds the list of available matchers and
// the state, that can hold matcher specific values that change over time.
const JEST_MATCHERS_OBJECT = Symbol.for('$$jest-matchers-object');
// Notes a built-in/internal Jest matcher.
// Jest may override the stack trace of Errors thrown by internal matchers.
const INTERNAL_MATCHER_FLAG = Symbol.for('$$jest-internal-matcher');
exports.INTERNAL_MATCHER_FLAG = INTERNAL_MATCHER_FLAG;
if (!Object.prototype.hasOwnProperty.call(globalThis, JEST_MATCHERS_OBJECT)) {
const defaultState = {
assertionCalls: 0,
expectedAssertionsNumber: null,
isExpectingAssertions: false,
numPassingAsserts: 0,
suppressedErrors: [] // errors that are not thrown immediately.
};
Object.defineProperty(globalThis, JEST_MATCHERS_OBJECT, {
value: {
customEqualityTesters: [],
matchers: Object.create(null),
state: defaultState
}
});
}
const getState = () => globalThis[JEST_MATCHERS_OBJECT].state;
exports.getState = getState;
const setState = state => {
Object.assign(globalThis[JEST_MATCHERS_OBJECT].state, state);
};
exports.setState = setState;
const getMatchers = () => globalThis[JEST_MATCHERS_OBJECT].matchers;
exports.getMatchers = getMatchers;
const setMatchers = (matchers, isInternal, expect) => {
Object.keys(matchers).forEach(key => {
const matcher = matchers[key];
if (typeof matcher !== 'function') {
throw new TypeError(
`expect.extend: \`${key}\` is not a valid matcher. Must be a function, is "${(0,
_jestGetType.getType)(matcher)}"`
);
}
Object.defineProperty(matcher, INTERNAL_MATCHER_FLAG, {
value: isInternal
});
if (!isInternal) {
// expect is defined
class CustomMatcher extends _asymmetricMatchers.AsymmetricMatcher {
constructor(inverse = false, ...sample) {
super(sample, inverse);
}
asymmetricMatch(other) {
const {pass} = matcher.call(
this.getMatcherContext(),
other,
...this.sample
);
return this.inverse ? !pass : pass;
}
toString() {
return `${this.inverse ? 'not.' : ''}${key}`;
}
getExpectedType() {
return 'any';
}
toAsymmetricMatcher() {
return `${this.toString()}<${this.sample.map(String).join(', ')}>`;
}
}
Object.defineProperty(expect, key, {
configurable: true,
enumerable: true,
value: (...sample) => new CustomMatcher(false, ...sample),
writable: true
});
Object.defineProperty(expect.not, key, {
configurable: true,
enumerable: true,
value: (...sample) => new CustomMatcher(true, ...sample),
writable: true
});
}
});
Object.assign(globalThis[JEST_MATCHERS_OBJECT].matchers, matchers);
};
exports.setMatchers = setMatchers;
const getCustomEqualityTesters = () =>
globalThis[JEST_MATCHERS_OBJECT].customEqualityTesters;
exports.getCustomEqualityTesters = getCustomEqualityTesters;
const addCustomEqualityTesters = newTesters => {
if (!Array.isArray(newTesters)) {
throw new TypeError(
`expect.customEqualityTesters: Must be set to an array of Testers. Was given "${(0,
_jestGetType.getType)(newTesters)}"`
);
}
globalThis[JEST_MATCHERS_OBJECT].customEqualityTesters.push(...newTesters);
};
exports.addCustomEqualityTesters = addCustomEqualityTesters;

1292
backend/apis/nodejs/node_modules/expect/build/matchers.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

122
backend/apis/nodejs/node_modules/expect/build/print.js generated vendored Normal file
View File

@ -0,0 +1,122 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.printReceivedStringContainExpectedSubstring =
exports.printReceivedStringContainExpectedResult =
exports.printReceivedConstructorNameNot =
exports.printReceivedConstructorName =
exports.printReceivedArrayContainExpectedItem =
exports.printExpectedConstructorNameNot =
exports.printExpectedConstructorName =
exports.printCloseTo =
void 0;
var _jestMatcherUtils = require('jest-matcher-utils');
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
/* eslint-disable local/ban-types-eventually */
// Format substring but do not enclose in double quote marks.
// The replacement is compatible with pretty-format package.
const printSubstring = val => val.replace(/"|\\/g, '\\$&');
const printReceivedStringContainExpectedSubstring = (
received,
start,
length // not end
) =>
(0, _jestMatcherUtils.RECEIVED_COLOR)(
`"${printSubstring(received.slice(0, start))}${(0,
_jestMatcherUtils.INVERTED_COLOR)(
printSubstring(received.slice(start, start + length))
)}${printSubstring(received.slice(start + length))}"`
);
exports.printReceivedStringContainExpectedSubstring =
printReceivedStringContainExpectedSubstring;
const printReceivedStringContainExpectedResult = (received, result) =>
result === null
? (0, _jestMatcherUtils.printReceived)(received)
: printReceivedStringContainExpectedSubstring(
received,
result.index,
result[0].length
);
// The serialized array is compatible with pretty-format package min option.
// However, items have default stringify depth (instead of depth - 1)
// so expected item looks consistent by itself and enclosed in the array.
exports.printReceivedStringContainExpectedResult =
printReceivedStringContainExpectedResult;
const printReceivedArrayContainExpectedItem = (received, index) =>
(0, _jestMatcherUtils.RECEIVED_COLOR)(
`[${received
.map((item, i) => {
const stringified = (0, _jestMatcherUtils.stringify)(item);
return i === index
? (0, _jestMatcherUtils.INVERTED_COLOR)(stringified)
: stringified;
})
.join(', ')}]`
);
exports.printReceivedArrayContainExpectedItem =
printReceivedArrayContainExpectedItem;
const printCloseTo = (receivedDiff, expectedDiff, precision, isNot) => {
const receivedDiffString = (0, _jestMatcherUtils.stringify)(receivedDiff);
const expectedDiffString = receivedDiffString.includes('e')
? // toExponential arg is number of digits after the decimal point.
expectedDiff.toExponential(0)
: 0 <= precision && precision < 20
? // toFixed arg is number of digits after the decimal point.
// It may be a value between 0 and 20 inclusive.
// Implementations may optionally support a larger range of values.
expectedDiff.toFixed(precision + 1)
: (0, _jestMatcherUtils.stringify)(expectedDiff);
return (
`Expected precision: ${isNot ? ' ' : ''} ${(0,
_jestMatcherUtils.stringify)(precision)}\n` +
`Expected difference: ${isNot ? 'not ' : ''}< ${(0,
_jestMatcherUtils.EXPECTED_COLOR)(expectedDiffString)}\n` +
`Received difference: ${isNot ? ' ' : ''} ${(0,
_jestMatcherUtils.RECEIVED_COLOR)(receivedDiffString)}`
);
};
exports.printCloseTo = printCloseTo;
const printExpectedConstructorName = (label, expected) =>
`${printConstructorName(label, expected, false, true)}\n`;
exports.printExpectedConstructorName = printExpectedConstructorName;
const printExpectedConstructorNameNot = (label, expected) =>
`${printConstructorName(label, expected, true, true)}\n`;
exports.printExpectedConstructorNameNot = printExpectedConstructorNameNot;
const printReceivedConstructorName = (label, received) =>
`${printConstructorName(label, received, false, false)}\n`;
// Do not call function if received is equal to expected.
exports.printReceivedConstructorName = printReceivedConstructorName;
const printReceivedConstructorNameNot = (label, received, expected) =>
typeof expected.name === 'string' &&
expected.name.length !== 0 &&
typeof received.name === 'string' &&
received.name.length !== 0
? `${printConstructorName(label, received, true, false)} ${
Object.getPrototypeOf(received) === expected
? 'extends'
: 'extends … extends'
} ${(0, _jestMatcherUtils.EXPECTED_COLOR)(expected.name)}\n`
: `${printConstructorName(label, received, false, false)}\n`;
exports.printReceivedConstructorNameNot = printReceivedConstructorNameNot;
const printConstructorName = (label, constructor, isNot, isExpected) =>
typeof constructor.name !== 'string'
? `${label} name is not a string`
: constructor.name.length === 0
? `${label} name is an empty string`
: `${label}: ${!isNot ? '' : isExpected ? 'not ' : ' '}${
isExpected
? (0, _jestMatcherUtils.EXPECTED_COLOR)(constructor.name)
: (0, _jestMatcherUtils.RECEIVED_COLOR)(constructor.name)
}`;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,481 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = exports.createMatcher = void 0;
var _expectUtils = require('@jest/expect-utils');
var _jestMatcherUtils = require('jest-matcher-utils');
var _jestMessageUtil = require('jest-message-util');
var _print = require('./print');
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
/* eslint-disable local/ban-types-eventually */
const DID_NOT_THROW = 'Received function did not throw';
const getThrown = e => {
const hasMessage =
e !== null && e !== undefined && typeof e.message === 'string';
if (hasMessage && typeof e.name === 'string' && typeof e.stack === 'string') {
return {
hasMessage,
isError: true,
message: e.message,
value: e
};
}
return {
hasMessage,
isError: false,
message: hasMessage ? e.message : String(e),
value: e
};
};
const createMatcher = (matcherName, fromPromise) =>
function (received, expected) {
const options = {
isNot: this.isNot,
promise: this.promise
};
let thrown = null;
if (fromPromise && (0, _expectUtils.isError)(received)) {
thrown = getThrown(received);
} else {
if (typeof received !== 'function') {
if (!fromPromise) {
const placeholder = expected === undefined ? '' : 'expected';
throw new Error(
(0, _jestMatcherUtils.matcherErrorMessage)(
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
placeholder,
options
),
`${(0, _jestMatcherUtils.RECEIVED_COLOR)(
'received'
)} value must be a function`,
(0, _jestMatcherUtils.printWithType)(
'Received',
received,
_jestMatcherUtils.printReceived
)
)
);
}
} else {
try {
received();
} catch (e) {
thrown = getThrown(e);
}
}
}
if (expected === undefined) {
return toThrow(matcherName, options, thrown);
} else if (typeof expected === 'function') {
return toThrowExpectedClass(matcherName, options, thrown, expected);
} else if (typeof expected === 'string') {
return toThrowExpectedString(matcherName, options, thrown, expected);
} else if (expected !== null && typeof expected.test === 'function') {
return toThrowExpectedRegExp(matcherName, options, thrown, expected);
} else if (
expected !== null &&
typeof expected.asymmetricMatch === 'function'
) {
return toThrowExpectedAsymmetric(matcherName, options, thrown, expected);
} else if (expected !== null && typeof expected === 'object') {
return toThrowExpectedObject(matcherName, options, thrown, expected);
} else {
throw new Error(
(0, _jestMatcherUtils.matcherErrorMessage)(
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
),
`${(0, _jestMatcherUtils.EXPECTED_COLOR)(
'expected'
)} value must be a string or regular expression or class or error`,
(0, _jestMatcherUtils.printWithType)(
'Expected',
expected,
_jestMatcherUtils.printExpected
)
)
);
}
};
exports.createMatcher = createMatcher;
const matchers = {
toThrow: createMatcher('toThrow'),
toThrowError: createMatcher('toThrowError')
};
const toThrowExpectedRegExp = (matcherName, options, thrown, expected) => {
const pass = thrown !== null && expected.test(thrown.message);
const message = pass
? () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
) +
'\n\n' +
formatExpected('Expected pattern: not ', expected) +
(thrown !== null && thrown.hasMessage
? formatReceived(
'Received message: ',
thrown,
'message',
expected
) + formatStack(thrown)
: formatReceived('Received value: ', thrown, 'value'))
: () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
) +
'\n\n' +
formatExpected('Expected pattern: ', expected) +
(thrown === null
? `\n${DID_NOT_THROW}`
: thrown.hasMessage
? formatReceived('Received message: ', thrown, 'message') +
formatStack(thrown)
: formatReceived('Received value: ', thrown, 'value'));
return {
message,
pass
};
};
const toThrowExpectedAsymmetric = (matcherName, options, thrown, expected) => {
const pass = thrown !== null && expected.asymmetricMatch(thrown.value);
const message = pass
? () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
) +
'\n\n' +
formatExpected('Expected asymmetric matcher: not ', expected) +
'\n' +
(thrown !== null && thrown.hasMessage
? formatReceived('Received name: ', thrown, 'name') +
formatReceived('Received message: ', thrown, 'message') +
formatStack(thrown)
: formatReceived('Thrown value: ', thrown, 'value'))
: () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
) +
'\n\n' +
formatExpected('Expected asymmetric matcher: ', expected) +
'\n' +
(thrown === null
? DID_NOT_THROW
: thrown.hasMessage
? formatReceived('Received name: ', thrown, 'name') +
formatReceived('Received message: ', thrown, 'message') +
formatStack(thrown)
: formatReceived('Thrown value: ', thrown, 'value'));
return {
message,
pass
};
};
const toThrowExpectedObject = (matcherName, options, thrown, expected) => {
const expectedMessageAndCause = createMessageAndCause(expected);
const thrownMessageAndCause =
thrown !== null ? createMessageAndCause(thrown.value) : null;
const pass =
thrown !== null &&
thrown.message === expected.message &&
thrownMessageAndCause === expectedMessageAndCause;
const message = pass
? () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
) +
'\n\n' +
formatExpected(
`Expected ${messageAndCause(expected)}: not `,
expectedMessageAndCause
) +
(thrown !== null && thrown.hasMessage
? formatStack(thrown)
: formatReceived('Received value: ', thrown, 'value'))
: () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
) +
'\n\n' +
(thrown === null
? // eslint-disable-next-line prefer-template
formatExpected(
`Expected ${messageAndCause(expected)}: `,
expectedMessageAndCause
) +
'\n' +
DID_NOT_THROW
: thrown.hasMessage
? // eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.printDiffOrStringify)(
expectedMessageAndCause,
thrownMessageAndCause,
`Expected ${messageAndCause(expected)}`,
`Received ${messageAndCause(thrown.value)}`,
true
) +
'\n' +
formatStack(thrown)
: formatExpected(
`Expected ${messageAndCause(expected)}: `,
expectedMessageAndCause
) + formatReceived('Received value: ', thrown, 'value'));
return {
message,
pass
};
};
const toThrowExpectedClass = (matcherName, options, thrown, expected) => {
const pass = thrown !== null && thrown.value instanceof expected;
const message = pass
? () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
) +
'\n\n' +
(0, _print.printExpectedConstructorNameNot)(
'Expected constructor',
expected
) +
(thrown !== null &&
thrown.value != null &&
typeof thrown.value.constructor === 'function' &&
thrown.value.constructor !== expected
? (0, _print.printReceivedConstructorNameNot)(
'Received constructor',
thrown.value.constructor,
expected
)
: '') +
'\n' +
(thrown !== null && thrown.hasMessage
? formatReceived('Received message: ', thrown, 'message') +
formatStack(thrown)
: formatReceived('Received value: ', thrown, 'value'))
: () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
) +
'\n\n' +
(0, _print.printExpectedConstructorName)(
'Expected constructor',
expected
) +
(thrown === null
? `\n${DID_NOT_THROW}`
: `${
thrown.value != null &&
typeof thrown.value.constructor === 'function'
? (0, _print.printReceivedConstructorName)(
'Received constructor',
thrown.value.constructor
)
: ''
}\n${
thrown.hasMessage
? formatReceived('Received message: ', thrown, 'message') +
formatStack(thrown)
: formatReceived('Received value: ', thrown, 'value')
}`);
return {
message,
pass
};
};
const toThrowExpectedString = (matcherName, options, thrown, expected) => {
const pass = thrown !== null && thrown.message.includes(expected);
const message = pass
? () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
) +
'\n\n' +
formatExpected('Expected substring: not ', expected) +
(thrown !== null && thrown.hasMessage
? formatReceived(
'Received message: ',
thrown,
'message',
expected
) + formatStack(thrown)
: formatReceived('Received value: ', thrown, 'value'))
: () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
undefined,
options
) +
'\n\n' +
formatExpected('Expected substring: ', expected) +
(thrown === null
? `\n${DID_NOT_THROW}`
: thrown.hasMessage
? formatReceived('Received message: ', thrown, 'message') +
formatStack(thrown)
: formatReceived('Received value: ', thrown, 'value'));
return {
message,
pass
};
};
const toThrow = (matcherName, options, thrown) => {
const pass = thrown !== null;
const message = pass
? () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
'',
options
) +
'\n\n' +
(thrown !== null && thrown.hasMessage
? formatReceived('Error name: ', thrown, 'name') +
formatReceived('Error message: ', thrown, 'message') +
formatStack(thrown)
: formatReceived('Thrown value: ', thrown, 'value'))
: () =>
// eslint-disable-next-line prefer-template
(0, _jestMatcherUtils.matcherHint)(
matcherName,
undefined,
'',
options
) +
'\n\n' +
DID_NOT_THROW;
return {
message,
pass
};
};
const formatExpected = (label, expected) =>
`${label + (0, _jestMatcherUtils.printExpected)(expected)}\n`;
const formatReceived = (label, thrown, key, expected) => {
if (thrown === null) {
return '';
}
if (key === 'message') {
const message = thrown.message;
if (typeof expected === 'string') {
const index = message.indexOf(expected);
if (index !== -1) {
return `${
label +
(0, _print.printReceivedStringContainExpectedSubstring)(
message,
index,
expected.length
)
}\n`;
}
} else if (expected instanceof RegExp) {
return `${
label +
(0, _print.printReceivedStringContainExpectedResult)(
message,
typeof expected.exec === 'function' ? expected.exec(message) : null
)
}\n`;
}
return `${label + (0, _jestMatcherUtils.printReceived)(message)}\n`;
}
if (key === 'name') {
return thrown.isError
? `${label + (0, _jestMatcherUtils.printReceived)(thrown.value.name)}\n`
: '';
}
if (key === 'value') {
return thrown.isError
? ''
: `${label + (0, _jestMatcherUtils.printReceived)(thrown.value)}\n`;
}
return '';
};
const formatStack = thrown =>
thrown === null || !thrown.isError
? ''
: (0, _jestMessageUtil.formatStackTrace)(
(0, _jestMessageUtil.separateMessageFromStack)(thrown.value.stack)
.stack,
{
rootDir: process.cwd(),
testMatch: []
},
{
noStackTrace: false
}
);
function createMessageAndCauseMessage(error) {
if (error.cause instanceof Error) {
return `{ message: ${error.message}, cause: ${createMessageAndCauseMessage(
error.cause
)}}`;
}
return `{ message: ${error.message} }`;
}
function createMessageAndCause(error) {
if (error.cause instanceof Error) {
return createMessageAndCauseMessage(error);
}
return error.message;
}
function messageAndCause(error) {
return error.cause === undefined ? 'message' : 'message and cause';
}
var _default = matchers;
exports.default = _default;

View File

@ -0,0 +1,3 @@
'use strict';
var _jestMatchersObject = require('./jestMatchersObject');

43
backend/apis/nodejs/node_modules/expect/package.json generated vendored Normal file
View File

@ -0,0 +1,43 @@
{
"name": "expect",
"version": "29.7.0",
"repository": {
"type": "git",
"url": "https://github.com/jestjs/jest.git",
"directory": "packages/expect"
},
"license": "MIT",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"default": "./build/index.js"
},
"./package.json": "./package.json",
"./build/matchers": "./build/matchers.js",
"./build/toThrowMatchers": "./build/toThrowMatchers.js"
},
"dependencies": {
"@jest/expect-utils": "^29.7.0",
"jest-get-type": "^29.6.3",
"jest-matcher-utils": "^29.7.0",
"jest-message-util": "^29.7.0",
"jest-util": "^29.7.0"
},
"devDependencies": {
"@fast-check/jest": "^1.3.0",
"@jest/test-utils": "^29.7.0",
"@tsd/typescript": "^5.0.4",
"chalk": "^4.0.0",
"immutable": "^4.0.0",
"tsd-lite": "^0.7.0"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
}