]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Add tests for weird moment clones
authorIskren Chernev <iskren.chernev@gmail.com>
Tue, 14 Jan 2014 07:16:24 +0000 (23:16 -0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Tue, 14 Jan 2014 07:16:46 +0000 (23:16 -0800)
test/moment/create.js
test/moment/is_moment.js

index 6baf65f7bc1fa08e8f81b57f9a6cd9f4cdf433f4..d65de741e0a1db6fa7e2a20a0308f887f171aa59 100644 (file)
@@ -105,6 +105,21 @@ exports.create = {
         test.done();
     },
 
+    "cloning moment works with weird clones" : function (test) {
+        var extend = function(a, b) {
+                var i;
+                for (i in b) {
+                    a[i] = b[i];
+                }
+                return a;
+            },
+            now = moment();
+
+        test.expect(1);
+        test.equal(+extend({}, now).clone(), +now, "cloning extend-ed now is now");
+        test.done();
+    },
+
     "undefined" : function (test) {
         test.expect(1);
         test.ok(moment().toDate() instanceof Date, "undefined");
index 1fb49bcdadb77fe48aab43b3273ebabe207d8746..6972709264b70eca5cfdbf1733608d67bf819f75 100644 (file)
@@ -2,15 +2,23 @@ var moment = require('../../moment');
 
 exports.is_moment = {
     "is moment object": function (test) {
-        test.expect(11);
+        test.expect(12);
 
-        var MyObj = function () {};
+        var MyObj = function () {},
+            extend = function(a, b) {
+                var i;
+                for (i in b) {
+                    a[i] = b[i];
+                }
+                return a;
+            };
         MyObj.prototype.toDate = function () {
             return new Date();
         };
 
         test.ok(moment.isMoment(moment()), 'simple moment object');
         test.ok(moment.isMoment(moment('invalid date')), 'invalid moment object');
+        test.ok(moment.isMoment(extend({}, moment())), 'externally cloned moments are moments');
 
         test.ok(!moment.isMoment(new MyObj()), 'myObj is not moment object');
         test.ok(!moment.isMoment(moment), 'moment function is not moment object');