Skip to content

Commit e51ab4a

Browse files
committed
Do not render '0' dates
1 parent ac59153 commit e51ab4a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/templates/extension-detail.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ const ExtensionDetailTemplate = ({
253253
<ExtensionMetadata
254254
data={{
255255
name: "Publish Date",
256-
text: metadata.maven?.timestamp,
256+
// Count dates of 0 as undefined, so we don't render them
257+
text: metadata.maven?.timestamp > 0 ? metadata.maven?.timestamp : undefined,
257258
transformer: timestamp =>
258259
timestamp
259260
? format(new Date(+timestamp), "MMM dd, yyyy")

src/templates/extension-detail.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,4 +435,33 @@ describe("extension detail page", () => {
435435
expect(screen.getByText("Unlisted")).toBeTruthy()
436436
})
437437
})
438+
439+
// A date of '0' is invalid and should not be displayed
440+
describe("for an extension whose date is zero", () => {
441+
const previous = {}
442+
const next = {}
443+
444+
const category = "old-jewellery"
445+
const extension = {
446+
name: "Ancient JRuby",
447+
slug: "jruby-slug",
448+
metadata: {
449+
categories: [category], maven: { timestamp: "0" },
450+
},
451+
}
452+
453+
beforeEach(() => {
454+
render(
455+
<ExtensionDetailTemplate
456+
data={{ extension, previous, next }}
457+
location="/somewhere"
458+
/>
459+
)
460+
})
461+
462+
it("does not render a release date", () => {
463+
const publishDate = "Publish Date"
464+
expect(screen.queryByText(publishDate)).toBeFalsy()
465+
})
466+
})
438467
})

0 commit comments

Comments
 (0)