Skip to content

Commit

Permalink
test: use expectTypeOf for type testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 21, 2023
1 parent f3fa33d commit 6fcf328
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/utils/src/lodash.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -277,25 +285,27 @@ 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", () => {
const o: Record<string, number> = {
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 }>();
});
});

Expand Down

0 comments on commit 6fcf328

Please sign in to comment.