@@ -6,8 +6,8 @@ import api from '../lib/api'
6
6
import print from '../lib/print'
7
7
import { result as mockJson } from './mock.json'
8
8
9
- test ( 'single result' , function * ( t ) {
10
- const rst = yield suoxie ( 'internationalization ' )
9
+ test ( 'single result' , async t => {
10
+ const rst = await suoxie ( 'big ' )
11
11
12
12
// should got an object result
13
13
t . truthy ( rst )
@@ -16,11 +16,11 @@ test('single result', function * (t) {
16
16
t . is ( typeof rst . results . result , 'object' )
17
17
18
18
// should got correct result
19
- t . is ( rst . results . result . term , 'I18N ' )
19
+ t . is ( rst . results . result . term , 'B ' )
20
20
} )
21
21
22
- test ( 'multi result' , function * ( t ) {
23
- const rst = yield suoxie ( 'repository' )
22
+ test ( 'multi result' , async t => {
23
+ const rst = await suoxie ( 'repository' )
24
24
25
25
// should got an object result
26
26
t . truthy ( rst )
@@ -33,12 +33,15 @@ test('multi result', function * (t) {
33
33
t . is ( rst . results . result [ 0 ] . term , 'REPOS' )
34
34
} )
35
35
36
- test ( 'api' , function * ( t ) {
37
- const rst = yield api . fetchTerm ( 'application' )
36
+ test ( 'api' , async t => {
37
+ const rst = await api . fetchTerm ( 'application' )
38
38
39
39
// should return reject with an error
40
- t . throws ( api . fetchTerm ( ) , 'word must not be empty' )
41
- t . throws ( api . fetchTerm ( '' ) , 'word must not be empty' )
40
+ const expected = 'word must not be empty'
41
+ const err1 = await t . throws ( api . fetchTerm ( ) )
42
+ const err2 = await t . throws ( api . fetchTerm ( '' ) )
43
+ t . is ( err1 . message , expected )
44
+ t . is ( err2 . message , expected )
42
45
43
46
// pure result from api request should be xml
44
47
t . true ( rst . startsWith ( '<?xml' . toLowerCase ( ) ) )
0 commit comments