Skip to content
Browse files

add tests around cloning functions

  • Loading branch information...
1 parent cb5c003 commit c91973cf6ee6f7d396ea5ffe8e7ebe6de418538a @wilmoore wilmoore committed
Showing with 20 additions and 0 deletions.
  1. +20 −0 test/clone.js
View
20 test/clone.js
@@ -57,4 +57,24 @@ describe('clone', function(){
expect(cloned.a.b[3]).not.to.be(obj.a.b[3]);
});
+ it('object with functions', function() {
+ var func = function () { return 'original'; };
+ var host = { fluent: func };
+ var cloned = clone(host);
+
+ // cloned function matches original
+
+ expect(cloned.fluent).to.be(func);
+
+ // change cloned function (no longer matches original)
+
+ cloned.fluent = function () { return 'updated'; };
+ expect(cloned.fluent).not.to.be(func);
+ expect(cloned.fluent()).to.be('updated');
+
+ // original function is still in place
+
+ expect(func()).to.be('original');
+ });
+
});

0 comments on commit c91973c

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