-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlib.test.js
35 lines (30 loc) · 854 Bytes
/
lib.test.js
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
const assert = require('assert');
const lib = require('./lib');
async function en2Cn() {
const input = 'hello';
const expected = '你好';
const response = await lib(input);
const actual = response.translation[0];
assert.ok(actual === expected);
}
async function cn2En() {
const expected = 'hello';
const input = '你好';
const response = await lib(input);
const actual = response.translation[0];
assert.ok(actual === expected);
}
async function responseBody() {
const input = 'hello';
const response = await lib(input);
assert.ok(response.hasOwnProperty('basic'));
assert.ok(response.hasOwnProperty('translation'));
assert.ok(response.hasOwnProperty('web'));
}
async function init() {
await en2Cn();
await cn2En();
await responseBody();
console.log('Good job!')
}
init();