test/test_sources.rb in pdd-0.23.1 vs test/test_sources.rb in pdd-0.23.2
- old
+ new
@@ -1,6 +1,6 @@
-# Copyright (c) 2014-2022 Yegor Bugayenko
+# Copyright (c) 2014-2023 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -24,11 +24,11 @@
require_relative '../test/test__helper'
require_relative '../lib/pdd/sources'
# Sources test.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
-# Copyright:: Copyright (c) 2014-2022 Yegor Bugayenko
+# Copyright:: Copyright (c) 2014-2023 Yegor Bugayenko
# License:: MIT
class TestSources < Minitest::Test
def test_iterator
in_temp(['a.txt', 'b/c.txt']) do |dir|
list = PDD::Sources.new(dir).fetch
@@ -52,11 +52,11 @@
end
end
def test_detects_all_text_files
in_temp([]) do |dir|
- exts = %w[(xsl java rb cpp apt)]
+ exts = %w[(xsl java rb cpp apt js xml c go h txt)]
exts.each do |ext|
File.write(File.join(dir, "test.#{ext}"), 'text')
end
list = PDD::Sources.new(dir).fetch
assert_equal(
@@ -67,9 +67,17 @@
end
def test_detects_xml_file
in_temp(['a.xml']) do |dir|
File.write(File.join(dir, 'a.xml'), '<?xml version="1.0"?><hello/>')
+ list = PDD::Sources.new(dir).fetch
+ assert_equal 1, list.size
+ end
+ end
+
+ def test_detects_js_file
+ in_temp(['a.js']) do |dir|
+ File.write(File.join(dir, 'a.js'), "#!/usr/bin/env node\nconsole.log('Hi!');")
list = PDD::Sources.new(dir).fetch
assert_equal 1, list.size
end
end