-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.ts
48 lines (41 loc) · 1.03 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { assertEquals, fail } from "https://deno.land/std/testing/asserts.ts";
import { GTR } from "./mod.ts";
const gtr = new GTR();
Deno.test({
name: "Sources Staying Equal",
async fn() {
const source = "Ev çavkanî ye.";
const result = await gtr.translate(source);
assertEquals(source, result.orig);
assertEquals("ku", result.lang);
},
});
Deno.test({
name: "Options Working",
async fn() {
const sourceLang = "fr";
const result = await gtr.translate("jeans", {
sourceLang,
targetLang: "ru",
});
assertEquals(sourceLang, result.lang);
assertEquals(result.trans, "джинсы");
},
});
Deno.test({
name: "TTS Working",
async fn() {
const result = await gtr.tts("Hello, world!");
const length = (await result.arrayBuffer()).byteLength;
if (length < 1000) {
fail();
}
},
});
Deno.test({
name: "Language Getting Detected",
async fn() {
const result = await gtr.detect("Min nizanîbû Deno ew qas baş e.");
assertEquals("ku", result);
},
});