From 6fcf32864e43d6972c705e446070ad0fa88c1826 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Thu, 21 Dec 2023 11:44:45 +0900 Subject: [PATCH] test: use `expectTypeOf` for type testing --- packages/utils/src/lodash.test.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/utils/src/lodash.test.ts b/packages/utils/src/lodash.test.ts index 8d97c2ed..96ad2c15 100644 --- a/packages/utils/src/lodash.test.ts +++ b/packages/utils/src/lodash.test.ts @@ -1,4 +1,12 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { + afterEach, + beforeEach, + describe, + expect, + expectTypeOf, + it, + vi, +} from "vitest"; import { LruCache } from "./cache"; import { capitalize, @@ -277,12 +285,13 @@ describe(objectPick, () => { x: 0, y: 1, } as const; - const result = objectPick(o, ["x"]) satisfies { x: 0 }; + const result = objectPick(o, ["x"]); expect(result).toMatchInlineSnapshot(` { "x": 0, } `); + expectTypeOf(result).toEqualTypeOf<{ readonly x: 0 }>(); }); it("record", () => { @@ -290,12 +299,13 @@ describe(objectPick, () => { x: 0, y: 1, }; - const result = objectPick(o, ["x"]) satisfies { x: number }; + const result = objectPick(o, ["x"]); expect(result).toMatchInlineSnapshot(` { "x": 0, } `); + expectTypeOf(result).toEqualTypeOf<{ x: number }>(); }); });