Commit 7d23991a 7d23991a0923fd7f8247395376040bc78162166b by Nicolas Perriault

added unit tests for util's fileExt()

1 parent 08de888d
......@@ -159,7 +159,7 @@ function dump(value) {
*/
function fileExt(file) {
try {
return file.split('.').pop().toLowerCase();
return file.split('.').pop().toLowerCase().trim();
} catch(e) {
return '';
}
......
(function(t) {
t.comment('fileExt()');
var testCases = {
'foo.ext': 'ext',
'FOO.EXT': 'ext',
'a.ext': 'ext',
'.ext': 'ext',
'toto.': '',
' plop.ext ': 'ext'
};
for (var testCase in testCases) {
t.assertEquals(fileExt(testCase), testCases[testCase], 'fileExt() extract file extension');
}
t.comment('mergeObjects()');
var testCases = [
testCases = [
{
obj1: {a: 1}, obj2: {b: 2}, merged: {a: 1, b: 2}
},
......