Skip to content

Commit b9485fb

Browse files
committed
Add empty string constant
1 parent 14b08c5 commit b9485fb

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

packages/graph-explorer/src/connector/entities/scalar.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ describe("scalar", () => {
158158
expect(result).toBe("hello world");
159159
});
160160

161+
it("should return EMPTY_VALUE for empty string scalar", () => {
162+
const result = getDisplayValueForScalar(" ");
163+
expect(result).toBe(LABELS.EMPTY_VALUE);
164+
});
165+
161166
it("should return number for integer scalar", () => {
162167
const result = getDisplayValueForScalar(123456);
163168
expect(result).toBe("123,456");

packages/graph-explorer/src/connector/entities/scalar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ export function getDisplayValueForScalar(value: ScalarValue) {
9393
const typedValue = createTypedValue(value);
9494
switch (typedValue.type) {
9595
case "string":
96-
return typedValue.value;
96+
// Check for empty string
97+
return !typedValue.value.trim() ? LABELS.EMPTY_VALUE : typedValue.value;
9798
case "number":
9899
return new Intl.NumberFormat().format(typedValue.value);
99100
case "boolean":

packages/graph-explorer/src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ export const LABELS = {
3838
MISSING_TYPE: `${ASCII.LAQUO}No Type${ASCII.RAQUO}`,
3939
/** Shown when a value is missing */
4040
MISSING_VALUE: `${ASCII.LAQUO}No Value${ASCII.RAQUO}`,
41+
/** Shown when a value is empty (like empty string) */
42+
EMPTY_VALUE: `${ASCII.LAQUO}Empty Value${ASCII.RAQUO}`,
4143
} as const;

0 commit comments

Comments
 (0)