Repository: aurora Updated Branches: refs/heads/master c446504e6 -> 705f25611
Protect against null value in RoleQuota Reviewed at https://reviews.apache.org/r/63038/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/705f2561 Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/705f2561 Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/705f2561 Branch: refs/heads/master Commit: 705f25611df669a5ee0c33387653f4bbb449ffcc Parents: c446504 Author: David McLaughlin <[email protected]> Authored: Mon Oct 16 16:25:59 2017 -0700 Committer: David McLaughlin <[email protected]> Committed: Mon Oct 16 16:25:59 2017 -0700 ---------------------------------------------------------------------- ui/src/main/js/components/RoleQuota.js | 4 ++++ ui/src/main/js/components/__tests__/RoleQuota-test.js | 5 +++++ 2 files changed, 9 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/705f2561/ui/src/main/js/components/RoleQuota.js ---------------------------------------------------------------------- diff --git a/ui/src/main/js/components/RoleQuota.js b/ui/src/main/js/components/RoleQuota.js index 36a69b4..bb1b6e7 100644 --- a/ui/src/main/js/components/RoleQuota.js +++ b/ui/src/main/js/components/RoleQuota.js @@ -50,6 +50,10 @@ function findResource(resource) { const totalResources = (resources) => resources.map(findResource).reduce((acc, val) => acc + val); export default function RoleQuota({ quota }) { + if (isNully(quota)) { + return <div />; + } + // Only show quota types with non-zero values. const quotas = QUOTA_TYPE_ORDER.filter((t) => totalResources(quota[t].resources) > 0); http://git-wip-us.apache.org/repos/asf/aurora/blob/705f2561/ui/src/main/js/components/__tests__/RoleQuota-test.js ---------------------------------------------------------------------- diff --git a/ui/src/main/js/components/__tests__/RoleQuota-test.js b/ui/src/main/js/components/__tests__/RoleQuota-test.js index 57f332d..56a5240 100644 --- a/ui/src/main/js/components/__tests__/RoleQuota-test.js +++ b/ui/src/main/js/components/__tests__/RoleQuota-test.js @@ -32,4 +32,9 @@ describe('RoleQuota', () => { </tr>)).toBe(true); }); }); + + it('Renders when quota is null', () => { + const el = shallow(<RoleQuota />); + expect(el.contains(<div />)).toBe(true); + }); });
