mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
a42bd5fa1f
Reviewed By: quark-zju Differential Revision: D43139551 fbshipit-source-id: 08bc2c370c5f6519bd0602abadedf7fe20b2da4d
29 lines
718 B
TypeScript
29 lines
718 B
TypeScript
/**
|
|
* 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 {Logger} from '../isl-server/src/logger';
|
|
import type {Json} from './typeUtils';
|
|
|
|
export const mockLogger: Logger = {
|
|
log: jest.fn(),
|
|
info: jest.fn(),
|
|
warn: jest.fn(),
|
|
error: jest.fn(),
|
|
};
|
|
|
|
export function clone<T extends Json>(o: T): T {
|
|
return JSON.parse(JSON.stringify(o));
|
|
}
|
|
|
|
/**
|
|
* Returns a Promise which resolves after the current async tick is finished.
|
|
* Useful for testing code which `await`s.
|
|
*/
|
|
export function nextTick(): Promise<void> {
|
|
return new Promise(res => setTimeout(res, 0));
|
|
}
|