aboutsummaryrefslogtreecommitdiffstats
path: root/test/AngularSpec.js
diff options
context:
space:
mode:
authorIgor Minar2013-02-11 22:10:58 -0800
committerIgor Minar2013-02-11 22:11:07 -0800
commit035e0130f35c4ae1636ffc2822be4762c7b2cc4b (patch)
tree413ddf69f1de39f548760decfbe28325dfdce26d /test/AngularSpec.js
parent9e57ce0c7af742d15223b9d2aa1f9aed5792d007 (diff)
downloadangular.js-035e0130f35c4ae1636ffc2822be4762c7b2cc4b.tar.bz2
test(angular.copy): add tests for scenarios when target is missing
Diffstat (limited to 'test/AngularSpec.js')
-rw-r--r--test/AngularSpec.js23
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('');