Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add tests for weird moment clones

  • Loading branch information...
commit d08df925a5e5c132b366957567c484724a29cd12 1 parent 4804015
@ichernev authored
Showing with 25 additions and 2 deletions.
  1. +15 −0 test/moment/create.js
  2. +10 −2 test/moment/is_moment.js
View
15 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");
View
12 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');

0 comments on commit d08df92

Please sign in to comment.
Something went wrong with that request. Please try again.