Skip to content

Commit

Permalink
Fix rubocop errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Mar 29, 2023
1 parent a202fb2 commit 8587639
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/i18n-js/cli/check_command_test.rb
Expand Up @@ -6,11 +6,6 @@ class CheckCommandTest < Minitest::Test
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }

def assert_command_deprecation_message
assert_stderr_includes "WARNING: `i18n check` has been deprecated in " \
"favor of `i18n lint:translations`"
end

test "displays help" do
cli = I18nJS::CLI.new(
argv: %w[check --help],
Expand Down Expand Up @@ -168,4 +163,9 @@ def assert_command_deprecation_message
assert_includes output, "=> es: 0 missing, 0 extraneous, 2 ignored"
assert_includes output, "=> pt: 0 missing, 0 extraneous, 2 ignored"
end

private def assert_command_deprecation_message
assert_stderr_includes "WARNING: `i18n check` has been deprecated in " \
"favor of `i18n lint:translations`"
end
end
6 changes: 6 additions & 0 deletions test/i18n-js/cli/ui_test.rb
Expand Up @@ -22,6 +22,7 @@ def tty?
io.tty = true

ui = I18nJS::CLI::UI.new(stdout: io, stderr: io)

assert_equal "\e[33mhello\e[0m", ui.yellow("hello")
end

Expand All @@ -30,6 +31,7 @@ def tty?
io.tty = false

ui = I18nJS::CLI::UI.new(stdout: io, stderr: io)

assert_equal "hello", ui.yellow("hello")
end

Expand All @@ -39,22 +41,26 @@ def tty?
io.tty = true

ui = I18nJS::CLI::UI.new(stdout: io, stderr: io)

assert_equal "hello", ui.yellow("hello")
end

test "returns ansi text when colored is set" do
ui = I18nJS::CLI::UI.new(stdout: io, stderr: io, colored: true)

assert_equal "\e[33mhello\e[0m", ui.yellow("hello")
end

test "returns plain text when colored is not set" do
ui = I18nJS::CLI::UI.new(stdout: io, stderr: io, colored: false)

assert_equal "hello", ui.yellow("hello")
end

test "returns plain text when colored is set but so is NO_COLOR" do
ENV["NO_COLOR"] = "1"
ui = I18nJS::CLI::UI.new(stdout: io, stderr: io, colored: true)

assert_equal "hello", ui.yellow("hello")
end
end
1 change: 1 addition & 0 deletions test/i18n-js/export_files_plugin_test.rb
Expand Up @@ -17,6 +17,7 @@ class ExportScriptFilesPluginTest < Minitest::Test

actual_files =
I18nJS.call(config_file: "./test/config/export_files.yml")

assert_exported_files ["test/output/export_files.json"], actual_files
assert_file exported_file
assert_equal File.read("test/fixtures/expected/export_files.ts"),
Expand Down
2 changes: 2 additions & 0 deletions test/i18n-js/exporter_test.rb
Expand Up @@ -195,6 +195,7 @@ def transform(translations:)

# First run
actual_files = I18nJS.call(config_file: "./test/config/everything.yml")

assert_exported_files [exported_file_path], actual_files
exported_file_mtime = File.mtime(exported_file_path)

Expand All @@ -213,6 +214,7 @@ def transform(translations:)

# First run
actual_files = I18nJS.call(config_file: "./test/config/everything.yml")

assert_exported_files [exported_file_path], actual_files

# Change content of existed exported file (add space to the end of file).
Expand Down
2 changes: 2 additions & 0 deletions test/support/minitest.rb
Expand Up @@ -34,6 +34,7 @@ class Test

private def assert_file(path)
path = File.expand_path(path)

assert File.file?(path), "Expected #{path} to be a file"
end

Expand All @@ -46,6 +47,7 @@ class Test

private def assert_exported_files(expected_files, actual_files)
expected_files = expected_files.map {|path| File.expand_path(path) }.sort

assert_equal expected_files.size,
actual_files.size,
"Expected files to be equal in size " \
Expand Down

0 comments on commit 8587639

Please sign in to comment.