Skip to content

test: add unit coverage for src/utils/array.ts (#994) - #996

Merged
sonukapoor merged 2 commits into
OWASP:mainfrom
alexsmolya:test/array-utils-coverage-994
Aug 16, 2026
Merged

test: add unit coverage for src/utils/array.ts (#994)#996
sonukapoor merged 2 commits into
OWASP:mainfrom
alexsmolya:test/array-utils-coverage-994

Conversation

@alexsmolya

Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive unit test coverage for src/utils/array.ts (chunk, unique, and uniquePathArrays) in tests/utils/array.test.ts, addressing #994.

Test Coverage

  • chunk(items, size): exact multiples, trailing short groups, size larger than array, empty array input, size 1 chunking, object arrays, and input immutability.
  • unique(items): deduplication with first-seen order preservation, all-unique inputs, empty inputs, identical element collapsing, and input immutability.
  • uniquePathArrays(paths): path array deduplication, path element order distinctness, single vs multi-element paths, empty path deduplication, and input immutability.

Verification

  • npm test tests/utils/array.test.ts (18/18 passing)
  • npm run lint:tests (clean hygiene check)
  • npm run build (successful compilation)
  • npm test (all 112 suites / 1,424 tests passing)

Closes #994

Adds comprehensive unit tests for pure array utility functions:
- chunk(): exact multiples, final short group, size > length, empty input, size 1, object arrays, immutability.
- unique(): deduplication preserving first-seen order, all-unique array, empty array, identical elements, immutability.
- uniquePathArrays(): deduplicating path arrays while preserving distinct paths in order, different ordering distinctness, single vs multi-element paths, empty path deduplication, immutability.
@alexsmolya
alexsmolya requested a review from sonukapoor as a code owner August 14, 2026 21:42

@sonukapoor sonukapoor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thorough set. The edge cases (empty input, size larger than the array, size 1) and the no-mutation checks are exactly what I'd want here, and the uniquePathArrays coverage including empty-path dedup and order-sensitivity is a nice touch. Thanks for taking it.

@sonukapoor
sonukapoor merged commit d981cce into OWASP:main Aug 16, 2026
6 checks passed
@sonukapoor

Copy link
Copy Markdown
Collaborator

Merged - thank you @alexsmolya! If CVE Lite CLI has been useful to you, a star on the repo genuinely helps other developers find it - no obligation at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: add unit coverage for src/utils/array.ts

2 participants