Skip to content

Commit e194fef

Browse files
committed
スペースに変更
1 parent 3e4e40d commit e194fef

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/post/renderer.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,12 @@ describe("Renderer", () => {
488488
expect(labels.length).toBe(times.length);
489489
expect(labels[0]).toBe(firstLabel);
490490
expect(labels[labels.length - 1]).toBe(lastLabel);
491+
const visibleLabelCount: number = labels.filter(
492+
(label: string): boolean => label.trim().length > 0,
493+
).length;
494+
expect(visibleLabelCount).toBeLessThanOrEqual(MAX_VISIBLE_TIME_LABELS);
491495
expect(
492-
labels.filter((label: string): boolean => label.length > 0).length,
493-
).toBeLessThanOrEqual(MAX_VISIBLE_TIME_LABELS);
494-
expect(labels.some((label: string): boolean => label === "")).toBe(true);
496+
labels.some((label: string): boolean => label.trim().length === 0),
497+
).toBe(true);
495498
});
496499
});

src/post/renderer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
} from "./lib";
88

99
export const MAX_VISIBLE_TIME_LABELS: number = 12;
10+
const EMPTY_TIME_LABEL_PLACEHOLDER: string = " ";
1011

1112
const formatTimeLabels = (times: Date[]): string[] => {
1213
if (times.length === 0) {
@@ -31,7 +32,9 @@ const formatTimeLabels = (times: Date[]): string[] => {
3132
}
3233

3334
const normalizedIndex: number = index - 1;
34-
return normalizedIndex % spacing === 0 ? label : "";
35+
return normalizedIndex % spacing === 0
36+
? label
37+
: EMPTY_TIME_LABEL_PLACEHOLDER;
3538
},
3639
);
3740
};

0 commit comments

Comments
 (0)