Skip to content

Update tests flatten array #2675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exercises/practice/flatten-array/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"contributors": [
"ankorGH",
"gabriel376",
"jagdish-15",
"rchavarria",
"SleeplessByte",
"tejasbubane",
Expand Down
48 changes: 45 additions & 3 deletions exercises/practice/flatten-array/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[8c71dabd-da60-422d-a290-4a571471fb14]
description = "empty"

[d268b919-963c-442d-9f07-82b93f1b518c]
description = "no nesting"

[3f15bede-c856-479e-bb71-1684b20c6a30]
description = "flattens a nested array"

[c84440cc-bb3a-48a6-862c-94cf23f2815d]
description = "flattens array with just integers present"

Expand All @@ -14,8 +27,37 @@ description = "5 level nesting"
[d572bdba-c127-43ed-bdcd-6222ac83d9f7]
description = "6 level nesting"

[0705a8e5-dc86-4cec-8909-150c5e54fa9c]
description = "null values are omitted from the final result"

[c6cf26de-8ccd-4410-84bd-b9efd88fd2bc]
description = "consecutive null values at the front of the list are omitted from the final result"
include = false

[bc72da10-5f55-4ada-baf3-50e4da02ec8e]
description = "consecutive null values at the front of the array are omitted from the final result"
reimplements = "c6cf26de-8ccd-4410-84bd-b9efd88fd2bc"

[382c5242-587e-4577-b8ce-a5fb51e385a1]
description = "consecutive null values in the middle of the list are omitted from the final result"
include = false

[6991836d-0d9b-4703-80a0-3f1f23eb5981]
description = "consecutive null values in the middle of the array are omitted from the final result"
reimplements = "382c5242-587e-4577-b8ce-a5fb51e385a1"

[ef1d4790-1b1e-4939-a179-51ace0829dbd]
description = "6 level nest list with null values"
include = false

[dc90a09c-5376-449c-a7b3-c2d20d540069]
description = "6 level nested array with null values"
reimplements = "ef1d4790-1b1e-4939-a179-51ace0829dbd"

[85721643-705a-4150-93ab-7ae398e2942d]
description = "all values in nested list are null"
include = false

[51f5d9af-8f7f-4fb5-a156-69e8282cb275]
description = "all values in nested array are null"
reimplements = "85721643-705a-4150-93ab-7ae398e2942d"
12 changes: 10 additions & 2 deletions exercises/practice/flatten-array/flatten-array.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,21 @@ describe('FlattenArray', () => {
expect(flatten([1, 2, null])).toEqual([1, 2]);
});

xtest('6 level nest list with null values', () => {
xtest('consecutive null values at the front of the array are omitted from the final result', () => {
expect(flatten([null, null, 3])).toEqual([3]);
});

xtest('consecutive null values in the middle of the array are omitted from the final result', () => {
expect(flatten([1, null, null, 4])).toEqual([1, 4]);
});

xtest('6 level nested array with null values', () => {
expect(flatten([0, 2, [[2, 3], 8, [[100]], null, [[null]]], -2])).toEqual([
0, 2, 2, 3, 8, 100, -2,
]);
});

xtest('all values in nested list are null', () => {
xtest('all values in nested array are null', () => {
expect(
flatten([null, [[[null]]], null, null, [[null, null], null], null]),
).toEqual([]);
Expand Down