added unit tests for util's fileExt()
Showing
2 changed files
with
17 additions
and
2 deletions
... | @@ -159,7 +159,7 @@ function dump(value) { | ... | @@ -159,7 +159,7 @@ function dump(value) { |
159 | */ | 159 | */ |
160 | function fileExt(file) { | 160 | function fileExt(file) { |
161 | try { | 161 | try { |
162 | return file.split('.').pop().toLowerCase(); | 162 | return file.split('.').pop().toLowerCase().trim(); |
163 | } catch(e) { | 163 | } catch(e) { |
164 | return ''; | 164 | return ''; |
165 | } | 165 | } | ... | ... |
1 | (function(t) { | 1 | (function(t) { |
2 | t.comment('fileExt()'); | ||
3 | |||
4 | var testCases = { | ||
5 | 'foo.ext': 'ext', | ||
6 | 'FOO.EXT': 'ext', | ||
7 | 'a.ext': 'ext', | ||
8 | '.ext': 'ext', | ||
9 | 'toto.': '', | ||
10 | ' plop.ext ': 'ext' | ||
11 | }; | ||
12 | |||
13 | for (var testCase in testCases) { | ||
14 | t.assertEquals(fileExt(testCase), testCases[testCase], 'fileExt() extract file extension'); | ||
15 | } | ||
16 | |||
2 | t.comment('mergeObjects()'); | 17 | t.comment('mergeObjects()'); |
3 | 18 | ||
4 | var testCases = [ | 19 | testCases = [ |
5 | { | 20 | { |
6 | obj1: {a: 1}, obj2: {b: 2}, merged: {a: 1, b: 2} | 21 | obj1: {a: 1}, obj2: {b: 2}, merged: {a: 1, b: 2} |
7 | }, | 22 | }, | ... | ... |
-
Please register or sign in to post a comment