Skip to content

Commit 7dd6d70

Browse files
chore: Match.arrEq is not defined for arrays containing undefined (backport #1589) (#1590)
# Backport This will backport the following commits from `main` to `maintenance/v5.4`: - [chore: &#x60;Match.arrEq&#x60; is not defined for arrays containing &#x60;undefined&#x60; (#1589)](#1589) <!--- Backport version: 9.5.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) Co-authored-by: Rico Hermans <[email protected]>
1 parent d0239a5 commit 7dd6d70

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/tsconfig/validator.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ describe('Built-in matchers', () => {
9191
});
9292

9393
describe('Match.arrEq', () => {
94+
const arrayEl = anythingExceptUndefined();
95+
9496
test('pass', () => {
9597
fc.assert(
9698
fc.property(
9799
fc
98-
.array(fc.anything({ maxDepth: 0 }))
100+
.array(arrayEl)
99101
.chain((expected) =>
100102
fc.tuple(
101103
fc.constant(expected),
@@ -111,10 +113,10 @@ describe('Built-in matchers', () => {
111113
test('fail', () => {
112114
fc.assert(
113115
fc.property(
114-
fc.uniqueArray(fc.anything(), {
116+
fc.uniqueArray(arrayEl, {
115117
minLength: 1,
116118
}),
117-
fc.array(fc.anything()),
119+
fc.array(arrayEl),
118120
(possible, actualBase) => {
119121
const expected = possible.slice(0, -1);
120122
const actual = [...actualBase, possible.at(-1)];
@@ -229,3 +231,7 @@ describe('Object Validator', () => {
229231
);
230232
});
231233
});
234+
235+
function anythingExceptUndefined() {
236+
return fc.anything().filter((x) => x !== undefined);
237+
}

0 commit comments

Comments
 (0)