diff options
Diffstat (limited to 'test/AngularSpec.js')
| -rw-r--r-- | test/AngularSpec.js | 23 | 
1 files changed, 21 insertions, 2 deletions
| diff --git a/test/AngularSpec.js b/test/AngularSpec.js index e29bb16b..1ead504f 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -31,7 +31,7 @@ describe('angular', function() {        expect(copy(date) === date).toBeFalsy();      }); -    it("should copy array", function() { +    it("should deeply copy an array into an existing array", function() {        var src = [1, {name:"value"}];        var dst = [{key:"v"}];        expect(copy(src, dst)).toBe(dst); @@ -40,6 +40,15 @@ describe('angular', function() {        expect(dst[1]).not.toBe(src[1]);      }); +    it("should deeply copy an array into a new array", function() { +      var src = [1, {name:"value"}]; +      var dst = copy(src); +      expect(src).toEqual([1, {name:"value"}]); +      expect(dst).toEqual(src); +      expect(dst).not.toBe(src); +      expect(dst[1]).not.toBe(src[1]); +    }); +      it('should copy empty array', function() {        var src = [];        var dst = [{key: "v"}]; @@ -47,7 +56,7 @@ describe('angular', function() {        expect(dst).toEqual([]);      }); -    it("should copy object", function() { +    it("should deeply copy an object into an existing object", function() {        var src = {a:{name:"value"}};        var dst = {b:{key:"v"}};        expect(copy(src, dst)).toBe(dst); @@ -56,6 +65,16 @@ describe('angular', function() {        expect(dst.a).not.toBe(src.a);      }); +    it("should deeply copy an object into an existing object", function() { +      var src = {a:{name:"value"}}; +      var dst = copy(src, dst); +      expect(src).toEqual({a:{name:"value"}}); +      expect(dst).toEqual(src); +      expect(dst).not.toBe(src); +      expect(dst.a).toEqual(src.a); +      expect(dst.a).not.toBe(src.a); +    }); +      it("should copy primitives", function() {        expect(copy(null)).toEqual(null);        expect(copy('')).toBe(''); | 
