Skip to content

Commit

Permalink
chore: Match.arrEq is not defined for arrays containing undefined
Browse files Browse the repository at this point in the history
… (backport #1589) (#1590)

# Backport

This will backport the following commits from `main` to
`maintenance/v5.4`:
- [chore: `Match.arrEq` is not defined for arrays containing
`undefined`
(#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]>
  • Loading branch information
aws-cdk-automation and rix0rrr authored Dec 16, 2024
1 parent d0239a5 commit 7dd6d70
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/tsconfig/validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ describe('Built-in matchers', () => {
});

describe('Match.arrEq', () => {
const arrayEl = anythingExceptUndefined();

test('pass', () => {
fc.assert(
fc.property(
fc
.array(fc.anything({ maxDepth: 0 }))
.array(arrayEl)
.chain((expected) =>
fc.tuple(
fc.constant(expected),
Expand All @@ -111,10 +113,10 @@ describe('Built-in matchers', () => {
test('fail', () => {
fc.assert(
fc.property(
fc.uniqueArray(fc.anything(), {
fc.uniqueArray(arrayEl, {
minLength: 1,
}),
fc.array(fc.anything()),
fc.array(arrayEl),
(possible, actualBase) => {
const expected = possible.slice(0, -1);
const actual = [...actualBase, possible.at(-1)];
Expand Down Expand Up @@ -229,3 +231,7 @@ describe('Object Validator', () => {
);
});
});

function anythingExceptUndefined() {
return fc.anything().filter((x) => x !== undefined);
}

0 comments on commit 7dd6d70

Please sign in to comment.