Skip to content

Commit

Permalink
convert android translation mapper tests in sanitizer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jvigne committed Jul 17, 2023
1 parent b188e6b commit 58e2cf1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 58 deletions.
58 changes: 0 additions & 58 deletions test/mappers/android_translation_mapper_test.rb

This file was deleted.

26 changes: 26 additions & 0 deletions test/sanitizers/ios_to_android_sanitizer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@
module AdLocalize
module Sanitizers
class IOSToAndroidSanitizerTest < TestCase
test 'should not map nil value' do
assert_nil IOSToAndroidSanitizer.new.sanitize(value: nil)
end

test 'should not map empty value' do
assert_nil IOSToAndroidSanitizer.new.sanitize(value: nil)
end

test 'should map list of autorized characters for android' do
password_specialchar_error = "Caractères spéciaux autorisés : - / : ; ( ) € & @ . , ? ! ' [ ] { } # % ^ * + = _ | ~ < > $ £ ¥ ` ° \""
sanitized_value = IOSToAndroidSanitizer.new.sanitize(value: password_specialchar_error)
expected_value = "\"Caractères spéciaux autorisés : - / : ; ( ) € \\&#38; @ . , ? ! \\&#39; [ ] { } # % ^ * + = _ | ~ \\&lt; \\&gt; $ £ ¥ ` ° \\&#34;\""
assert_equal expected_value, sanitized_value
end

test 'should not escape "%" when not needed for android' do
percentage_value = "100%"
sanitized_value = IOSToAndroidSanitizer.new.sanitize(value: percentage_value)
assert_equal "\"100%\"", sanitized_value
end

test 'should escape "%" when needed for android' do
formatted_string_value = "%1$@ %"
sanitized_value = IOSToAndroidSanitizer.new.sanitize(value: formatted_string_value)
assert_equal "\"%1$s %%\"", sanitized_value
end
end
end
end

0 comments on commit 58e2cf1

Please sign in to comment.