15
15
16
16
'use strict' ;
17
17
18
- const path = require ( ` path` ) ;
19
- const test = require ( `ava` ) ;
20
- const tools = require ( ` @google-cloud/nodejs-repo-tools` ) ;
21
- const { Translate} = require ( ` @google-cloud/translate` ) ;
18
+ const path = require ( ' path' ) ;
19
+ const assert = require ( 'assert' ) ;
20
+ const tools = require ( ' @google-cloud/nodejs-repo-tools' ) ;
21
+ const { Translate} = require ( ' @google-cloud/translate' ) ;
22
22
const translate = new Translate ( ) ;
23
23
24
- const cwd = path . join ( __dirname , `..` ) ;
25
- const cmd = ` node translate.js` ;
26
- const text = ` Hello world!` ;
27
- const text2 = ` Goodbye!` ;
28
- const model = ` nmt` ;
29
- const toLang = `ru` ;
24
+ const cwd = path . join ( __dirname , '..' ) ;
25
+ const cmd = ' node translate.js' ;
26
+ const text = ' Hello world!' ;
27
+ const text2 = ' Goodbye!' ;
28
+ const model = ' nmt' ;
29
+ const toLang = 'ru' ;
30
30
31
- test . before ( tools . checkCredentials ) ;
31
+ before ( tools . checkCredentials ) ;
32
32
33
- test ( ` should detect language of a single string` , async t => {
33
+ it ( ' should detect language of a single string' , async ( ) => {
34
34
const output = await tools . runAsync ( `${ cmd } detect "${ text } "` , cwd ) ;
35
35
const [ detection ] = await translate . detect ( text ) ;
36
36
const expected = `Detections:\n${ text } => ${ detection . language } ` ;
37
- t . is ( output , expected ) ;
37
+ assert . strictEqual ( output , expected ) ;
38
38
} ) ;
39
39
40
- test ( ` should detect language of multiple strings` , async t => {
40
+ it ( ' should detect language of multiple strings' , async ( ) => {
41
41
const output = await tools . runAsync (
42
42
`${ cmd } detect "${ text } " "${ text2 } "` ,
43
43
cwd
@@ -46,32 +46,32 @@ test(`should detect language of multiple strings`, async t => {
46
46
const expected = `Detections:\n${ text } => ${
47
47
detections [ 0 ] . language
48
48
} \n${ text2 } => ${ detections [ 1 ] . language } `;
49
- t . is ( output , expected ) ;
49
+ assert . strictEqual ( output , expected ) ;
50
50
} ) ;
51
51
52
- test ( ` should list languages` , async t => {
52
+ it ( ' should list languages' , async ( ) => {
53
53
const output = await tools . runAsync ( `${ cmd } list` , cwd ) ;
54
- t . true ( output . includes ( ` Languages:` ) ) ;
55
- t . true ( output . includes ( `{ code: 'af', name: 'Afrikaans' }` ) ) ;
54
+ assert . ok ( output . includes ( ' Languages:' ) ) ;
55
+ assert . ok ( output . includes ( `{ code: 'af', name: 'Afrikaans' }` ) ) ;
56
56
} ) ;
57
57
58
- test ( ` should list languages with a target` , async t => {
58
+ it ( ' should list languages with a target' , async ( ) => {
59
59
const output = await tools . runAsync ( `${ cmd } list es` , cwd ) ;
60
- t . true ( output . includes ( ` Languages:` ) ) ;
61
- t . true ( output . includes ( `{ code: 'af', name: 'afrikáans' }` ) ) ;
60
+ assert . ok ( output . includes ( ' Languages:' ) ) ;
61
+ assert . ok ( output . includes ( `{ code: 'af', name: 'afrikáans' }` ) ) ;
62
62
} ) ;
63
63
64
- test ( ` should translate a single string` , async t => {
64
+ it ( ' should translate a single string' , async ( ) => {
65
65
const output = await tools . runAsync (
66
66
`${ cmd } translate ${ toLang } "${ text } "` ,
67
67
cwd
68
68
) ;
69
69
const [ translation ] = await translate . translate ( text , toLang ) ;
70
70
const expected = `Translations:\n${ text } => (${ toLang } ) ${ translation } ` ;
71
- t . is ( output , expected ) ;
71
+ assert . strictEqual ( output , expected ) ;
72
72
} ) ;
73
73
74
- test ( ` should translate multiple strings` , async t => {
74
+ it ( ' should translate multiple strings' , async ( ) => {
75
75
const output = await tools . runAsync (
76
76
`${ cmd } translate ${ toLang } "${ text } " "${ text2 } "` ,
77
77
cwd
@@ -80,20 +80,20 @@ test(`should translate multiple strings`, async t => {
80
80
const expected = `Translations:\n${ text } => (${ toLang } ) ${
81
81
translations [ 0 ]
82
82
} \n${ text2 } => (${ toLang } ) ${ translations [ 1 ] } `;
83
- t . is ( output , expected ) ;
83
+ assert . strictEqual ( output , expected ) ;
84
84
} ) ;
85
85
86
- test ( ` should translate a single string with a model` , async t => {
86
+ it ( ' should translate a single string with a model' , async ( ) => {
87
87
const output = await tools . runAsync (
88
88
`${ cmd } translate-with-model ${ toLang } ${ model } "${ text } "` ,
89
89
cwd
90
90
) ;
91
91
const [ translation ] = await translate . translate ( text , toLang ) ;
92
92
const expected = `Translations:\n${ text } => (${ toLang } ) ${ translation } ` ;
93
- t . is ( output , expected ) ;
93
+ assert . strictEqual ( output , expected ) ;
94
94
} ) ;
95
95
96
- test ( ` should translate multiple strings with a model` , async t => {
96
+ it ( ' should translate multiple strings with a model' , async ( ) => {
97
97
const output = await tools . runAsync (
98
98
`${ cmd } translate-with-model ${ toLang } ${ model } "${ text } " "${ text2 } "` ,
99
99
cwd
@@ -102,5 +102,5 @@ test(`should translate multiple strings with a model`, async t => {
102
102
const expected = `Translations:\n${ text } => (${ toLang } ) ${
103
103
translations [ 0 ]
104
104
} \n${ text2 } => (${ toLang } ) ${ translations [ 1 ] } `;
105
- t . is ( output , expected ) ;
105
+ assert . strictEqual ( output , expected ) ;
106
106
} ) ;
0 commit comments