Skip to content

Commit 3108af2

Browse files
committed
🌿 Improve tests of isPartialOf and isRequiredOf
1 parent 18cce08 commit 3108af2

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

is/__snapshots__/partial_of_test.ts.snap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ snapshot[`isPartialOf<T> > returns properly named function 1`] = `
77
isString,
88
isUndefined
99
])),
10-
c: asOptional(isBoolean)
10+
c: asOptional(isBoolean),
11+
d: asOptional(asReadonly(isString))
1112
})"
1213
`;
1314
@@ -18,6 +19,7 @@ snapshot[`isPartialOf<T> > returns properly named function 2`] = `
1819
isString,
1920
isUndefined
2021
])),
21-
c: asOptional(isBoolean)
22+
c: asOptional(isBoolean),
23+
d: asOptional(asReadonly(isString))
2224
})"
2325
`;

is/__snapshots__/required_of_test.ts.snap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ snapshot[`isRequiredOf<T> > returns properly named function 1`] = `
77
isString,
88
isUndefined
99
]),
10-
c: isBoolean
10+
c: isBoolean,
11+
d: asReadonly(isString)
1112
})"
1213
`;
1314
@@ -18,6 +19,7 @@ snapshot[`isRequiredOf<T> > returns properly named function 2`] = `
1819
isString,
1920
isUndefined
2021
]),
21-
c: isBoolean
22+
c: isBoolean,
23+
d: asReadonly(isString)
2224
})"
2325
`;

is/partial_of_test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Deno.test("isPartialOf<T>", async (t) => {
1111
a: is.Number,
1212
b: is.UnionOf([is.String, is.Undefined]),
1313
c: as.Optional(is.Boolean),
14+
d: as.Readonly(is.String),
1415
});
1516
await t.step("returns properly named function", async (t) => {
1617
await assertSnapshot(t, isPartialOf(pred).name);
@@ -21,7 +22,10 @@ Deno.test("isPartialOf<T>", async (t) => {
2122
const a: unknown = { a: 0, b: "a", c: true };
2223
if (isPartialOf(pred)(a)) {
2324
assertType<
24-
Equal<typeof a, Partial<{ a: number; b: string; c: boolean }>>
25+
Equal<
26+
typeof a,
27+
Partial<{ a: number; b: string; c: boolean; readonly d: string }>
28+
>
2529
>(true);
2630
}
2731
});

is/required_of_test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Deno.test("isRequiredOf<T>", async (t) => {
1111
a: is.Number,
1212
b: is.UnionOf([is.String, is.Undefined]),
1313
c: as.Optional(is.Boolean),
14+
d: as.Readonly(is.String),
1415
});
1516
await t.step("returns properly named function", async (t) => {
1617
await assertSnapshot(t, isRequiredOf(pred).name);
@@ -21,7 +22,10 @@ Deno.test("isRequiredOf<T>", async (t) => {
2122
const a: unknown = { a: 0, b: "a", c: true };
2223
if (isRequiredOf(pred)(a)) {
2324
assertType<
24-
Equal<typeof a, { a: number; b: string | undefined; c: boolean }>
25+
Equal<
26+
typeof a,
27+
{ a: number; b: string | undefined; c: boolean; readonly d: string }
28+
>
2529
>(true);
2630
}
2731
});

0 commit comments

Comments
 (0)