-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format node/relationship counts in sidebar, inspector and legend (#1008)
* commas-node-and-relation-count-new: initial * commas-node-and-relation-count-new: thousand comma separation utility created. naming needs looking at. * commas-node-and-relation-count: remove a classname added just for a test build * commas-node-and-relation-count-new: rename util to be more suitable and rework the function with logical operators * commas-node-and-relation-count-new: used alias for shared utils import path, added additional tests and reworked number-to-US-locale.js to allow 0 to be output as string to be consistent with other values * commas-node-and-relation-count-new: remove accidentally inserted local mock for node and relationship values
- Loading branch information
Jas Kuner
authored
Dec 6, 2019
1 parent
234d4c2
commit eac0ed1
Showing
5 changed files
with
125 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2002-2019 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* This file is part of Neo4j. | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
export default value => | ||
(parseInt(value, 10) >= 0 && parseInt(value, 10).toLocaleString('en-US')) || | ||
value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2002-2019 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/* global describe, test, expect */ | ||
import numberToUSLocale from './number-to-US-locale' | ||
|
||
describe('numberToUSLocale', () => { | ||
test('should return the original value if isNaN(value) is true', () => { | ||
// Given | ||
const value = null | ||
|
||
// When | ||
const returnValue = numberToUSLocale(value) | ||
|
||
// Then | ||
expect(returnValue).toBe(value) | ||
}) | ||
test('should return a non-comma separated number if isNaN(value) is false and 0 <= value < 1000', () => { | ||
let value, returnValue | ||
// Given | ||
value = 0 | ||
|
||
// When | ||
returnValue = numberToUSLocale(value) | ||
|
||
// Then | ||
expect(returnValue).toBe('0') | ||
|
||
// Given | ||
value = '10' | ||
|
||
// When | ||
returnValue = numberToUSLocale(value) | ||
|
||
// Then | ||
expect(returnValue).toBe('10') | ||
|
||
// Given | ||
value = 999 | ||
|
||
// When | ||
returnValue = numberToUSLocale(value) | ||
|
||
// Then | ||
expect(returnValue).toBe('999') | ||
}) | ||
test('should return a thousands comma separated number if isNaN(value) is false and value >= 1000 ', () => { | ||
let value, returnValue | ||
// Given | ||
value = 1000 | ||
|
||
// When | ||
returnValue = numberToUSLocale(value) | ||
|
||
// Then | ||
expect(returnValue).toBe('1,000') | ||
|
||
// Given | ||
value = '123456789' | ||
|
||
// When | ||
returnValue = numberToUSLocale(value) | ||
|
||
// Then | ||
expect(returnValue).toBe('123,456,789') | ||
|
||
// Given | ||
value = 987654312345 | ||
|
||
// When | ||
returnValue = numberToUSLocale(value) | ||
|
||
// Then | ||
expect(returnValue).toBe('987,654,312,345') | ||
}) | ||
}) |