added tests for utils' fillBlanks()
Showing
1 changed file
with
18 additions
and
0 deletions
1 | (function(t) { | 1 | (function(t) { |
2 | t.comment('fileExt()'); | 2 | t.comment('fileExt()'); |
3 | 3 | ||
4 | (function() { | ||
4 | var testCases = { | 5 | var testCases = { |
5 | 'foo.ext': 'ext', | 6 | 'foo.ext': 'ext', |
6 | 'FOO.EXT': 'ext', | 7 | 'FOO.EXT': 'ext', |
... | @@ -13,9 +14,25 @@ | ... | @@ -13,9 +14,25 @@ |
13 | for (var testCase in testCases) { | 14 | for (var testCase in testCases) { |
14 | t.assertEquals(fileExt(testCase), testCases[testCase], 'fileExt() extract file extension'); | 15 | t.assertEquals(fileExt(testCase), testCases[testCase], 'fileExt() extract file extension'); |
15 | } | 16 | } |
17 | })(); | ||
18 | |||
19 | t.comment('fillBlanks()'); | ||
20 | |||
21 | (function() { | ||
22 | testCases = { | ||
23 | 'foo': 'foo ', | ||
24 | ' foo bar ': ' foo bar ', | ||
25 | ' foo bar ': ' foo bar ' | ||
26 | }; | ||
27 | |||
28 | for (var testCase in testCases) { | ||
29 | t.assertEquals(fillBlanks(testCase, 10), testCases[testCase], 'fillBlanks() fills blanks'); | ||
30 | } | ||
31 | })(); | ||
16 | 32 | ||
17 | t.comment('mergeObjects()'); | 33 | t.comment('mergeObjects()'); |
18 | 34 | ||
35 | (function() { | ||
19 | testCases = [ | 36 | testCases = [ |
20 | { | 37 | { |
21 | obj1: {a: 1}, obj2: {b: 2}, merged: {a: 1, b: 2} | 38 | obj1: {a: 1}, obj2: {b: 2}, merged: {a: 1, b: 2} |
... | @@ -43,6 +60,7 @@ | ... | @@ -43,6 +60,7 @@ |
43 | testCases.forEach(function(testCase) { | 60 | testCases.forEach(function(testCase) { |
44 | t.assertEquals(mergeObjects(testCase.obj1, testCase.obj2), testCase.merged, 'mergeObjects() can merge objects'); | 61 | t.assertEquals(mergeObjects(testCase.obj1, testCase.obj2), testCase.merged, 'mergeObjects() can merge objects'); |
45 | }); | 62 | }); |
63 | })(); | ||
46 | 64 | ||
47 | t.done(); | 65 | t.done(); |
48 | })(casper.test); | 66 | })(casper.test); | ... | ... |
-
Please register or sign in to post a comment