var libPath = require('../lib/_libPath.js');
var merge = require('../' + libPath + '/merge');

describe('merge', function() {
    describe('+merge()', function() {
        it('should merge the passed objects together', function() { 
            var original = { a: "a", b: "b" };
            var secondary = { c: "c" };
            var expected = { a: "a", b: "b",c: "c" };
                     
            merge.merge(original, expected).should.eql(expected);  
        });
        
        it('should replace values in the original', function() {
            var original = { a: "a", b: "b" };
            var secondary = { a: "c" };
            var expected = { a: "c", b: "b" };
            
            merge.merge(original, expected).should.eql(expected);  
        });
        
        it('should should not merge non-recursively if not speficied', function() {
            var original = { a: "a", b: ["1", "2", "3"], c: { a: "a", b: "b", c: "c" } };
            var secondary = { b: ["1"], c: { a: "a" } };
            var expected = { a: "a", b: ["1"], c: { a: "a" } };
            
            merge.merge(original, expected).should.eql(expected);  
        });
        
        it('should should merge recursively if speficied', function() {
            var original = { a: "a", b: ["1", "2", "3"], c: { a: "a", b: "b", c: "c" } };
            var secondary = { b: ["1"], c: { d: "d" } };
            var expected = { a: "a", b: ["1", "2", "3", "1"], c: { a: "a", b: "b", c: "c", d: "d" } };
            
            merge.merge(original, expected, true).should.eql(expected);  
        });
    });
    
    describe('+clone()', function() {
        it('should copy the passed object', function() {
            var original = { a: "a", b: "b" };
            merge.clone(original).should.eql(original);
            
            original = { a: "a", b: { c: "c", d: "d" } };
            merge.clone(original).should.eql(original);
            
            original = { a: "a", b: ["c", "d", "e"] };
            merge.clone(original).should.eql(original);
            
            original = null; 
            (merge.clone(original) == null).should.be.true;
        });
        
        it('should copy the passed array', function() {
            var original = [ "a", "b", "c" ];
            merge.clone(original).should.eql(original);
            
            original = [ [ "a", "b", "c" ], "d", "e" ];
            merge.clone(original).should.eql(original);
        });
        
        
        it('use an objects clone method if defined', function() {
            function CloneableObject() {
                if(!(this instanceof CloneableObject)) { return new CloneableObject(); }

                this.cloned = false;
                this.clone = function() {
                    this.cloned = true;
                    return this;
                }
            }
            
            var object = new CloneableObject();
            
            merge.clone(object).cloned.should.be.true;
        });
        
        
    });
});
@@ -2175,32 +2175,518 @@
    %7D);%0A        %0A
+%0A        it('should prevent changes to the original object affecting the copy', function() %7B%0A            var original = %7B a: %22a%22, b: %22b%22 %7D;%0A            var output = merge.clone(original);%0A            original = %7B b: %22c%22 %7D%0A            output.should.not.equal(original);%0A            %0A            original = %7B a: %22a%22, b: %7B c: %22c%22 %7D %7D%0A            output = merge.clone(original);%0A            original.c = %22d%22;%0A            output.should.not.equal(original);%0A        %7D);%0A                    %0A%0A
         it('shou

Add additional specification for the merge class