utils.test.js
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var chai = require('chai')
, expect = chai.expect
, Utils = require(__dirname + '/../lib/utils')
describe("Utils", function() {
describe('removeCommentsFromFunctionString', function() {
it("removes line comments at the start of a line", function() {
var functionWithLineComments = function() {
// noot noot
}
var string = functionWithLineComments.toString()
, result = Utils.removeCommentsFromFunctionString(string)
expect(result).not.to.match(/.*noot.*/)
})
it("removes lines comments in the middle of a line", function() {
var functionWithLineComments = function() {
alert(1) // noot noot
}
var string = functionWithLineComments.toString()
, result = Utils.removeCommentsFromFunctionString(string)
expect(result).not.to.match(/.*noot.*/)
})
it("removes range comments", function() {
var s = function() {
alert(1) /*
noot noot
*/
alert(2) /*
foo
*/
}.toString()
var result = Utils.removeCommentsFromFunctionString(s)
expect(result).not.to.match(/.*noot.*/)
expect(result).not.to.match(/.*foo.*/)
expect(result).to.match(/.*alert\(2\).*/)
})
})
})