Fix countdown localization issue #2003
Annotations
2 errors
qa.spec.ts > QA > js/octorelay.js build remains:
ui/qa.spec.ts#L12
Error: Snapshot `QA > js/octorelay.js build remains 1` mismatched
- Expected
+ Received
@@ -17,18 +17,25 @@
if (timeLeft >= 60) {
timeLeft /= 60;
unit = "hour";
}
const isLastMinute = unit === "minute" && timeLeft < 2;
- const formattedTimeLeft = new Intl.NumberFormat(LOCALE, {
- style: "unit",
+ for (const locale of [LOCALE, void 0]) {
+ try {
+ const formattedTimeLeft = new Intl.NumberFormat(locale, {
+ style: "unit",
- unitDisplay: "long",
+ unitDisplay: "long",
- minimumFractionDigits: isLastMinute ? 1 : 0,
+ minimumFractionDigits: isLastMinute ? 1 : 0,
- maximumFractionDigits: isLastMinute ? 1 : 0,
+ maximumFractionDigits: isLastMinute ? 1 : 0,
- unit
+ unit
- }).format(Math.max(0, timeLeft));
+ }).format(Math.max(0, timeLeft));
- return `in ${formattedTimeLeft}`;
+ return `in ${formattedTimeLeft}`;
+ } catch (error) {
+ console.warn(`Failed to format time using ${locale} locale`, error);
+ }
+ }
+ return `in ${time} seconds`;
};
var getCountdownDelay = (deadline) => deadline - Date.now() > 12e4 ? 6e4 : 1e3;
var setCountdown = (selector, deadline) => {
const delay = getCountdownDelay(deadline);
let disposer;
❯ qa.spec.ts:12:20
|
UI
Process completed with exit code 1.
|