mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
mock type changes (#3305)
* Update mock types and set bun-types@latest in bun init * Remove mockfn methods from toplevel mock * Remove comments
This commit is contained in:
34
packages/bun-types/bun-test.d.ts
vendored
34
packages/bun-types/bun-test.d.ts
vendored
@@ -27,43 +27,11 @@ declare module "bun:test" {
|
||||
|
||||
export const mock: {
|
||||
<T extends AnyFunction>(Function: T): Mock<T>;
|
||||
|
||||
mockClear(): typeof mock;
|
||||
mockReset(): typeof mock;
|
||||
mockRestore(): void;
|
||||
mockReturnValue<T extends JestMock.FunctionLike = JestMock.UnknownFunction>(
|
||||
value: ReturnType<T>,
|
||||
): JestMock.MockInstance<T>;
|
||||
mockReturnValueOnce<
|
||||
T extends JestMock.FunctionLike = JestMock.UnknownFunction,
|
||||
>(
|
||||
value: ReturnType<T>,
|
||||
): JestMock.MockInstance<T>;
|
||||
mockResolvedValue<
|
||||
T extends JestMock.FunctionLike = JestMock.UnknownFunction,
|
||||
>(
|
||||
value: JestMock.ResolveType<T>,
|
||||
): JestMock.MockInstance<T>;
|
||||
mockResolvedValueOnce<
|
||||
T extends JestMock.FunctionLike = JestMock.UnknownFunction,
|
||||
>(
|
||||
value: JestMock.ResolveType<T>,
|
||||
): JestMock.MockInstance<T>;
|
||||
mockRejectedValue<
|
||||
T extends JestMock.FunctionLike = JestMock.UnknownFunction,
|
||||
>(
|
||||
value: JestMock.RejectType<T>,
|
||||
): JestMock.MockInstance<T>;
|
||||
mockRejectedValueOnce<
|
||||
T extends JestMock.FunctionLike = JestMock.UnknownFunction,
|
||||
>(
|
||||
value: JestMock.RejectType<T>,
|
||||
): JestMock.MockInstance<T>;
|
||||
};
|
||||
|
||||
interface Jest {
|
||||
restoreAllMocks(): void;
|
||||
fn<T extends AnyFunction>(func: T): Mock<T>;
|
||||
fn<T extends AnyFunction>(func?: T): Mock<T>;
|
||||
}
|
||||
export const jest: Jest;
|
||||
export namespace jest {
|
||||
|
||||
@@ -14,4 +14,18 @@ declare var arg2: arg2;
|
||||
arg2.mock.calls[0];
|
||||
mock;
|
||||
|
||||
type _arg3 = jest.Mock<() => number>;
|
||||
// @ts-expect-error
|
||||
jest.fn<() => Promise<string>>().mockReturnValue("asdf");
|
||||
// @ts-expect-error
|
||||
jest.fn<() => string>().mockReturnValue(24);
|
||||
jest.fn<() => string>().mockReturnValue("24");
|
||||
|
||||
jest.fn<() => Promise<string>>().mockResolvedValue("asdf");
|
||||
// @ts-expect-error
|
||||
jest.fn<() => string>().mockResolvedValue(24);
|
||||
// @ts-expect-error
|
||||
jest.fn<() => string>().mockResolvedValue("24");
|
||||
|
||||
jest.fn().mockClear();
|
||||
jest.fn().mockReset();
|
||||
jest.fn().mockRejectedValueOnce(new Error());
|
||||
|
||||
@@ -300,13 +300,7 @@ pub const InitCommand = struct {
|
||||
|
||||
if (needs_dev_dependencies) {
|
||||
var dev_dependencies = fields.object.get("devDependencies") orelse js_ast.Expr.init(js_ast.E.Object, js_ast.E.Object{}, logger.Loc.Empty);
|
||||
const version = comptime brk: {
|
||||
var base = Global.version;
|
||||
base.patch = 0;
|
||||
break :brk base;
|
||||
};
|
||||
|
||||
try dev_dependencies.data.e_object.putString(alloc, "bun-types", comptime std.fmt.comptimePrint("^{any}", .{version.fmt("")}));
|
||||
try dev_dependencies.data.e_object.putString(alloc, "bun-types", "latest");
|
||||
try fields.object.put(alloc, "devDependencies", dev_dependencies);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user