Skip to content

Commit 609c124

Browse files
committed
test: update tests
1 parent b6bb89f commit 609c124

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

.travis.yml

-11
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ sudo: false
22

33
language: node_js
44

5-
env:
6-
- CXX="g++-4.8"
7-
85
node_js:
96
- 4
107
- 5
@@ -14,11 +11,3 @@ node_js:
1411
cache:
1512
directories:
1613
- node_modules
17-
18-
addons:
19-
apt:
20-
sources:
21-
- ubuntu-toolchain-r-test
22-
packages:
23-
- g++-4.8
24-
- gcc-4.8

test/test.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import api from '../lib/api'
66
import print from '../lib/print'
77
import { result as mockJson } from './mock.json'
88

9-
test('single result', function * (t) {
10-
const rst = yield suoxie('internationalization')
9+
test('single result', async t => {
10+
const rst = await suoxie('big')
1111

1212
// should got an object result
1313
t.truthy(rst)
@@ -16,11 +16,11 @@ test('single result', function * (t) {
1616
t.is(typeof rst.results.result, 'object')
1717

1818
// should got correct result
19-
t.is(rst.results.result.term, 'I18N')
19+
t.is(rst.results.result.term, 'B')
2020
})
2121

22-
test('multi result', function * (t) {
23-
const rst = yield suoxie('repository')
22+
test('multi result', async t => {
23+
const rst = await suoxie('repository')
2424

2525
// should got an object result
2626
t.truthy(rst)
@@ -33,12 +33,15 @@ test('multi result', function * (t) {
3333
t.is(rst.results.result[0].term, 'REPOS')
3434
})
3535

36-
test('api', function * (t) {
37-
const rst = yield api.fetchTerm('application')
36+
test('api', async t => {
37+
const rst = await api.fetchTerm('application')
3838

3939
// 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)
4245

4346
// pure result from api request should be xml
4447
t.true(rst.startsWith('<?xml'.toLowerCase()))

0 commit comments

Comments
 (0)