DEV: Locale dates test needs to set default moment timzone.

DEV: Locale dates test needs to set default moment timzone.

The tests were breaking on a machine configured to use SGT timezone.

From 9cf9dee4ccfec546e0e6502be522f847ffb1cf5a Mon Sep 17 00:00:00 2001
From: Guo Xiang Tan <tgx_world@hotmail.com>
Date: Tue, 27 Nov 2018 13:50:25 +0800
Subject: [PATCH] DEV: Locale dates test needs to set default moment timzone.

The tests were breaking on a machine configured to use SGT timezone.

diff --git a/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-test.js.es6 b/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-test.js.es6
index 90ee9ab..2e0ad23 100644
--- a/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-test.js.es6
+++ b/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-test.js.es6
@@ -37,6 +37,7 @@ function freezeDateAndZone(date, zone, cb) {
   sandbox.restore();
   sandbox.stub(moment.tz, "guess");
   moment.tz.guess.returns(zone);
+  moment.tz.setDefault(zone);
 
   const now = moment(date).valueOf();
   sandbox.useFakeTimers(now);
@@ -126,7 +127,7 @@ test("yesterday", assert => {
   );
 });
 
-QUnit.skip("yesterday - no time", assert => {
+test("yesterday - no time", assert => {
   const html = generateHTML({ date: rewind(1) });
   const transformed = $(html).applyLocalDates();
 
@@ -200,7 +201,7 @@ test("recurring", assert => {
     "it displays the next occurrence"
   );
 
-  freezeDateAndZone(advance(1), () => {
+  freezeDateAndZone(advance(1), null, () => {
     transformed = $(html).applyLocalDates();
 
     assert.equal(
@@ -363,6 +364,7 @@ test("test utils", assert => {
     moment(DEFAULT_DATE).format("LLLL"),
     "it has defaults"
   );
+
   assert.equal(moment.tz.guess(), DEFAULT_ZONE, "it has defaults");
 
   freezeDateAndZone(advance(1), DEFAULT_ZONE, () => {

GitHub

2 Likes