Skip to content

Commit

Permalink
Add translation test case for DeepL::Translator
Browse files Browse the repository at this point in the history
  • Loading branch information
kojix2 committed Jan 30, 2025
1 parent 475a8ed commit 5477efc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec"
{% if flag?(:deepl_mock) %}
STDERR.puts " Using mock for DeepL API ".colorize.back(:magenta)
require "./crest_extension_for_mock"
STDERR.puts " Using mock for DeepL API ".colorize.back(:magenta)
require "./crest_extension_for_mock"
{% end %}
require "../src/deepl"
7 changes: 7 additions & 0 deletions spec/translator_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,11 @@ describe DeepL::Translator do
output_file.parent.should eq(Path[__DIR__] / "fixtures")
output_file.basename.to_s.should match(/sample_PT-BR_\d{10}.txt/)
end

{% if flag?(:deepl_mock) %}
it "can translate text using mock" do
t = DeepL::Translator.new
t.translate_text("proton beam", "DE", "EN").should eq("Protonenstrahl")
end
{% end %}
end

0 comments on commit 5477efc

Please sign in to comment.