2017-06-13 07:11:43 +00:00
|
|
|
local dutch_wikipedia_text = "Wikipedia is een meertalige encyclopedie, waarvan de inhoud vrij beschikbaar is. Iedereen kan hier kennis toevoegen!"
|
2017-08-08 20:35:40 +00:00
|
|
|
local Translator
|
2017-06-13 07:11:43 +00:00
|
|
|
|
|
|
|
describe("Translator module", function()
|
|
|
|
setup(function()
|
|
|
|
require("commonrequire")
|
|
|
|
Translator = require("ui/translator")
|
|
|
|
end)
|
|
|
|
it("should return server", function()
|
2018-12-16 17:02:38 +00:00
|
|
|
assert.is.same("https://translate.googleapis.com/", Translator:getTransServer())
|
2017-06-13 07:11:43 +00:00
|
|
|
G_reader_settings:saveSetting("trans_server", "http://translate.google.nl")
|
|
|
|
G_reader_settings:flush()
|
|
|
|
assert.is.same("http://translate.google.nl", Translator:getTransServer())
|
|
|
|
G_reader_settings:delSetting("trans_server")
|
|
|
|
G_reader_settings:flush()
|
|
|
|
end)
|
2018-12-16 17:02:38 +00:00
|
|
|
-- add " #notest #nocov" to the it("description string") when it does not work anymore
|
2023-09-24 16:18:03 +00:00
|
|
|
it("should return translation #internet", function()
|
2018-12-16 17:02:38 +00:00
|
|
|
local translation_result = Translator:translate(dutch_wikipedia_text, "en")
|
2017-06-13 07:11:43 +00:00
|
|
|
assert.is.truthy(translation_result)
|
|
|
|
-- while some minor variation in the translation is possible it should
|
|
|
|
-- be between about 100 and 130 characters
|
|
|
|
assert.is_true(#translation_result > 50 and #translation_result < 200)
|
|
|
|
end)
|
2023-09-24 16:18:03 +00:00
|
|
|
it("should autodetect language #internet", function()
|
2017-06-13 07:11:43 +00:00
|
|
|
local detect_result = Translator:detect(dutch_wikipedia_text)
|
|
|
|
assert.is.same("nl", detect_result)
|
|
|
|
end)
|
|
|
|
end)
|