From 849bc3033a141e49d1b4c1914a5a51258624f181 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 25 Jun 2024 11:09:33 +0200 Subject: [PATCH] Fixed render time-based test (#781) Signed-off-by: marcopiraccini --- test/renderer/utilityDetails.test.mjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/renderer/utilityDetails.test.mjs b/test/renderer/utilityDetails.test.mjs index c80e1613..808c92fe 100644 --- a/test/renderer/utilityDetails.test.mjs +++ b/test/renderer/utilityDetails.test.mjs @@ -20,9 +20,15 @@ test('return label donwloads', async () => { }) test('return label released At', async () => { - expect('54 years ago').toEqual(getLabelReleasedAt('0')) - expect('54 years ago').toEqual(getLabelReleasedAt(0)) - expect('54 years ago').toEqual(getLabelReleasedAt(0)) + const today = new Date() + const oneDay = 1000 * 60 * 60 * 24 + const result = Math.round((today.getTime() / oneDay)) + const numberOfDaysSinceEpoch = result.toFixed(0) + const numberOfYearsSinceEpoch = (numberOfDaysSinceEpoch / 365).toFixed(0) + + expect(`${numberOfYearsSinceEpoch} years ago`).toEqual(getLabelReleasedAt('0')) + expect(`${numberOfYearsSinceEpoch} years ago`).toEqual(getLabelReleasedAt(0)) + expect(`${numberOfYearsSinceEpoch} years ago`).toEqual(getLabelReleasedAt(0)) expect('-').toEqual(getLabelReleasedAt('-')) expect('-').toEqual(getLabelReleasedAt(null)) expect('-').toEqual(getLabelReleasedAt(undefined))