Skip to content

Commit

Permalink
Merge pull request #40 from trayio/taniya-amidon/CSP-3693/utils-bug-f…
Browse files Browse the repository at this point in the history
…ix-for-deleteemptyobjects-method

[CSP-3693] utils bug fix for deletEemptyobjects method
  • Loading branch information
TaniyaAmidon authored Jun 8, 2020
2 parents a402013 + 78d18b4 commit abc46dc
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 51 deletions.
2 changes: 1 addition & 1 deletion lib/removeEmptyObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const removeEmptyObjects = collection => {
// this will remove empty objects if the child element was populated on first iteration and is now empty.
return _.isEmpty(clean_object) ? null : clean_object;
}
return undefined;
return collection;
};

module.exports = removeEmptyObjects;
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 49 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
{
"name": "@trayio/connector-utils",
"version": "0.3.0",
"description": "Common utility functions used in connectors.",
"main": "lib/index.js",
"scripts": {
"coverage": "npm run test -- --coverage",
"lint": "./node_modules/.bin/eslint . --fix",
"test": "jest tests",
"test:watch": "jest tests --watch --notify"
},
"repository": {
"type": "git",
"url": "git+https://github.com/trayio/falafel-utils.git"
},
"keywords": [
"falafel",
"connectors"
],
"files": [
"index.js",
"/lib"
],
"author": "tray.io",
"license": "ISC",
"bugs": {
"url": "https://github.com/trayio/connector-utils/issues"
},
"homepage": "https://github.com/trayio/connector-utils#readme",
"devDependencies": {
"@trayio/connector-test-runner": "^0.5.0",
"@trayio/falafel": "^1.26.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-promise": "^4.2.1",
"jest": "^25.1.0",
"jest-json-schema": "^2.1.0",
"jsdoc-to-markdown": "^5.0.3",
"prettier": "^1.19.1"
},
"dependencies": {
"lodash": "~4.17.15",
"mustache": "^4.0.1"
}
}
"name": "@trayio/connector-utils",
"version": "0.3.1",
"description": "Common utility functions used in connectors.",
"main": "lib/index.js",
"scripts": {
"coverage": "npm run test -- --coverage",
"lint": "./node_modules/.bin/eslint . --fix",
"test": "jest tests",
"test:watch": "jest tests --watch --notify"
},
"repository": {
"type": "git",
"url": "git+https://github.com/trayio/falafel-utils.git"
},
"keywords": [
"falafel",
"connectors"
],
"files": [
"index.js",
"/lib"
],
"author": "tray.io",
"license": "ISC",
"bugs": {
"url": "https://github.com/trayio/connector-utils/issues"
},
"homepage": "https://github.com/trayio/connector-utils#readme",
"devDependencies": {
"@trayio/connector-test-runner": "^0.5.0",
"@trayio/falafel": "^1.26.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-promise": "^4.2.1",
"jest": "^25.1.0",
"jest-json-schema": "^2.1.0",
"jsdoc-to-markdown": "^5.0.3",
"prettier": "^1.19.1"
},
"dependencies": {
"lodash": "~4.17.15",
"mustache": "^4.0.1"
}
}
14 changes: 14 additions & 0 deletions tests/methods/removeEmptyObjects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ describe('Helper should remove all empty objects from the payload', () => {
key2: 'someval',
key3: {},
key4: 'other value',
key5: ['foo', 'bar'],
}),
).toEqual({
key2: 'someval',
key4: 'other value',
key5: ['foo', 'bar'],
});
});

Expand Down Expand Up @@ -140,4 +142,16 @@ describe('Helper should remove all empty objects from the payload', () => {
},
});
});
test('It does not remove string type values from arrays', () => {
expect(
removeEmptyObjects({
key: ['foo', 'bar'],
key1: [],
key2: [{ foo: 'bar' }],
}),
).toEqual({
key: ['foo', 'bar'],
key2: [{ foo: 'bar' }],
});
});
});

0 comments on commit abc46dc

Please sign in to comment.