Skip to content

Commit

Permalink
add tests around cloning functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wilmoore committed May 7, 2013
1 parent cb5c003 commit c91973c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/clone.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,4 +57,24 @@ describe('clone', function(){
expect(cloned.a.b[3]).not.to.be(obj.a.b[3]); 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.