added tests for utils' mergeObjects()
Showing
1 changed file
with
33 additions
and
0 deletions
tests/suites/utils.js
0 → 100644
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); |
-
Please register or sign in to post a comment