test/test_chatgpt.rb in jekyll-chatgpt-translate-0.0.19 vs test/test_chatgpt.rb in jekyll-chatgpt-translate-0.0.20
- old
+ new
@@ -22,29 +22,55 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
require 'minitest/autorun'
require 'webmock/minitest'
+require_relative 'test__helper'
require_relative '../lib/jekyll-chatgpt-translate/chatgpt'
# ChatGPT test.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2023 Yegor Bugayenko
# License:: MIT
class GptTranslate::ChatGPTTest < Minitest::Test
def test_short_text
- chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'en', 'ru')
+ chat = GptTranslate::ChatGPT.new('fake-key', 'foo', 'xx', 'xx')
assert_equal('Hello, world!', chat.translate('Hello, world!'))
end
def test_dry_mode
- chat = GptTranslate::ChatGPT.new('', 'gpt-3.5-turbo', 'en', 'ru')
- assert_equal(38, chat.translate('This text should not be sent to OpenAI').length)
+ chat = GptTranslate::ChatGPT.new('', 'foo', 'xx', 'xx')
+ assert_equal(38, chat.translate('This text should not be sent to OpenAI', min: 100).length)
end
+ def test_no_translation
+ chat = GptTranslate::ChatGPT.new('', 'foo', 'xx', 'xx')
+ chat.translate(
+ "
+ How are you, my friend?
+
+ Read this Java code:
+
+ ```
+ System.out.println(\"Hello, dude!\");
+ System.out.println(\"Good bye!\");
+ System.out.println(\"Done!\");
+ ```
+
+ This is it.
+ ",
+ min: 40
+ )
+ end
+
def test_markup
- chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'en', 'ru')
+ chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'xx', 'xx')
assert_equal('<img src="a"/>', chat.translate('<img src="a"/>'))
+ end
+
+ def test_code_block
+ chat = GptTranslate::ChatGPT.new('fake-key', '', 'xx', 'xx')
+ chat.translate("```\ntest\n```", min: 0)
end
def test_through_webmock
stub_request(:any, 'https://api.openai.com/v1/chat/completions')
.to_return(body: '{"choices":[{"message":{"content": "boom!"}}]}')