Skip to content
This repository has been archived by the owner on Jun 30, 2020. It is now read-only.

Commit

Permalink
stacking returns items of null instead of empty arrays
Browse files Browse the repository at this point in the history
in YAML this means no key/value instead of a key and a value of empty collection
  • Loading branch information
grahamdyson committed Jul 9, 2019
1 parent 58086fb commit 39f3a41
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -91,5 +91,5 @@
"spellcheck": "find -type f \\( -name \"*.js\" -or -name \"*.md\" \\) ! -path \"./dist/*\" ! -path \"./dist/**/*\" ! -path \"./node_modules/**/*\" ! -path \"./test-coverage/**/*\" -exec npx cspell {} +",
"test": "npx jest --runInBand"
},
"version": "7.1.0"
"version": "7.2.0"
}
Expand Up @@ -40,8 +40,13 @@ module.exports =
targetLevelOrStack,
});

return getStackOrSingleLevelOrSingleItem(stackForTarget);

return (
stackForTarget.length
?
getStackOrSingleLevelOrSingleItem(stackForTarget)
:
null
);

function createExistingFactory() {
let hasExisting = false;
Expand Down
Expand Up @@ -3,6 +3,18 @@ This library is free software, licensed under the terms of the GNU General Publi

const createStackWhenIdentifierOrItemOrLevelOrAddWhenStack = require(".");

test(
"Null and target of existing returns null.",
() =>
expect(
createStackWhenIdentifierOrItemOrLevelOrAddWhenStack({
identifierOrItemOrLevelOrStack: null,
targetLevelOrStack: [ "existing" ],
}),
)
.toBeNull(),
);

test(
"Identifier in target returns identifier.",
() =>
Expand Down

0 comments on commit 39f3a41

Please sign in to comment.