]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
fixing flaky test
authorTim Wood <washwithcare@gmail.com>
Tue, 6 Nov 2012 18:20:52 +0000 (10:20 -0800)
committerTim Wood <washwithcare@gmail.com>
Tue, 6 Nov 2012 18:20:52 +0000 (10:20 -0800)
test/moment/utc.js

index 26a66a28c20aa0b4b2da6ea8fc8b497d7412d05a..60457f2768e2a6d8518136fd45cc3399a4e69fe8 100644 (file)
@@ -30,7 +30,11 @@ exports.utc = {
     "creating with utc" : function(test) {
         test.expect(7);
 
-        test.equal(moment.utc().valueOf(), moment().valueOf(), "Calling moment.utc() should default to the current time");
+        var diff = moment.utc().valueOf() - moment().valueOf();
+        diff = Math.abs(diff);
+        // we check the diff rather than equality because sometimes they are off by a millisecond
+
+        test.ok(diff < 5, "Calling moment.utc() should default to the current time");
 
         var m = moment.utc([2011, 1, 2, 3, 4, 5, 6]);
         test.equal(m.date(), 2, "the day should be correct for utc array");