Add tests for variable decleration with 'let'
This commit is contained in:
@@ -37,10 +37,22 @@ class TC_Extensions < Test::Unit::TestCase
|
||||
|
||||
def test_safe_client_debug_log
|
||||
Dir['../../extensions/**/*.js'].each do |path|
|
||||
next if /extensions\/admin_ui/.match(path) # skip this file
|
||||
next if /extensions\/admin_ui/.match(path) # skip this directory
|
||||
next unless File.file?(path)
|
||||
File.open(path) do |f|
|
||||
f.grep(/\W*console\.log\W*\(/im) do |line|
|
||||
assert(false, "Function 'console.log' used instead of 'beef.debug' in command module: " + path + ':' + line)
|
||||
f.grep(/\bconsole\.log\W*\(/m) do |line|
|
||||
assert(false, "Function 'console.log' used instead of 'beef.debug' in extension: " + path + ':' + line)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_safe_variable_decleration
|
||||
Dir['../../extensions/**/*.js'].each do |path|
|
||||
next unless File.file?(path)
|
||||
File.open(path) do |f|
|
||||
f.grep(/\blet\W+[a-zA-Z0-9_\.]+\W*=/) do |line|
|
||||
assert(false, "Variable decleration with 'let' used instead of 'var' in extension: " + path + ':' + line)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,12 +50,24 @@ class TC_Modules < Test::Unit::TestCase
|
||||
|
||||
def test_safe_client_debug_log
|
||||
Dir['../../modules/**/*.js'].each do |path|
|
||||
next unless File.file?(path)
|
||||
File.open(path) do |f|
|
||||
f.grep(/\W*console\.log\W*\(/im) do |line|
|
||||
f.grep(/\bconsole\.log\W*\(/m) do |line|
|
||||
assert(false, "Function 'console.log' used instead of 'beef.debug' in command module: " + path + ':' + line)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_safe_variable_decleration
|
||||
Dir['../../modules/**/*.js'].each do |path|
|
||||
next unless File.file?(path)
|
||||
File.open(path) do |f|
|
||||
f.grep(/\blet\W+[a-zA-Z0-9_\.]+\W*=/) do |line|
|
||||
assert(false, "Variable decleration with 'let' used instead of 'var' in command module: " + path + ':' + line)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user