From: Iskren Chernev Date: Tue, 14 Jan 2014 07:16:24 +0000 (-0800) Subject: Add tests for weird moment clones X-Git-Tag: 2.5.1~5^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d08df925a5e5c132b366957567c484724a29cd12;p=thirdparty%2Fmoment.git Add tests for weird moment clones --- diff --git a/test/moment/create.js b/test/moment/create.js index 6baf65f7b..d65de741e 100644 --- a/test/moment/create.js +++ b/test/moment/create.js @@ -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"); diff --git a/test/moment/is_moment.js b/test/moment/is_moment.js index 1fb49bcda..697270926 100644 --- a/test/moment/is_moment.js +++ b/test/moment/is_moment.js @@ -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');