Skip to content

Commit dd8301d

Browse files
committed
added test to test functionality 'folder as destination'
1 parent 5dec4e7 commit dd8301d

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

Gruntfile.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ module.exports = function (grunt) {
4242
'test/fixtures/file2.js'
4343
]
4444
}
45+
},
46+
47+
folderDest: {
48+
options: {
49+
},
50+
files: {
51+
'tmp/': [
52+
'test/fixtures/file3.js',
53+
'test/fixtures/folder/file4.js'
54+
]
55+
}
4556
}
4657
},
4758

test/fixtures/file3.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function ask(what) {
2+
var upper = what.toUpperCase();
3+
return upper + '?';
4+
}
5+
module.exports = ask;

test/fixtures/folder/file4.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function doubt(what) {
2+
var upper = what.toLowerCase();
3+
return upper + '...';
4+
}
5+
module.exports = doubt;

test/test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ exports.obfuscator = {
4141
// tests whether the obfuscation worked
4242
test.ok(result.indexOf('Forty Two') === -1);
4343

44+
test.done();
45+
},
46+
folderDest: function(test) {
47+
test.expect(4);
48+
49+
var result1 = readFile('tmp/test/fixtures/file3.js');
50+
var result2 = readFile('tmp/test/fixtures/folder/file4.js');
51+
52+
var ask = eval(result1);
53+
test.equal(ask('Hello World'), 'HELLO WORLD?');
54+
55+
var doubt = eval(result2);
56+
test.equal(doubt('Hello World'), 'hello world...');
57+
58+
// tests whether the obfuscation worked
59+
test.ok(result1.indexOf('toUpperCase') === -1);
60+
test.ok(result2.indexOf('toLowerCase') === -1);
61+
4462
test.done();
4563
}
4664
};

0 commit comments

Comments
 (0)