Add tests for variable decleration with 'let'

This commit is contained in:
Brendan Coles
2017-08-06 18:39:23 +00:00
parent 5a2a74c6a7
commit 4ff956c9be
2 changed files with 28 additions and 4 deletions

View File

@@ -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