diff --git a/test/unit/core/tc_extensions.rb b/test/unit/core/tc_extensions.rb index ac8cd0495..e39bb7b36 100644 --- a/test/unit/core/tc_extensions.rb +++ b/test/unit/core/tc_extensions.rb @@ -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 diff --git a/test/unit/core/tc_modules.rb b/test/unit/core/tc_modules.rb index b0feb1648..a0271353c 100644 --- a/test/unit/core/tc_modules.rb +++ b/test/unit/core/tc_modules.rb @@ -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