Commit 08de888d 08de888dae1616401a8c3538367956f9fda1de67 by Nicolas Perriault

added tests for utils' mergeObjects()

1 parent 1e9df674
1 (function(t) {
2 t.comment('mergeObjects()');
3
4 var testCases = [
5 {
6 obj1: {a: 1}, obj2: {b: 2}, merged: {a: 1, b: 2}
7 },
8 {
9 obj1: {}, obj2: {a: 1}, merged: {a: 1}
10 },
11 {
12 obj1: {a: 1}, obj2: {}, merged: {a: 1}
13 },
14 {
15 obj1: {a: 1}, obj2: {a: 2}, merged: {a: 2}
16 },
17 {
18 obj1: {x: 0, double: function(){return this.x*2;}},
19 obj2: {triple: function(){return this.x*3;}},
20 merged: {
21 x: 0,
22 double: function(){return this.x*2;},
23 triple: function(){return this.x*3;}
24 }
25 }
26 ];
27
28 testCases.forEach(function(testCase) {
29 t.assertEquals(mergeObjects(testCase.obj1, testCase.obj2), testCase.merged, 'mergeObjects() can merge objects');
30 });
31
32 t.done();
33 })(casper.test);