Skip to content

Commit b05aebb

Browse files
committed
Added tests for config
1 parent 4d5c781 commit b05aebb

File tree

3 files changed

+1280
-39
lines changed

3 files changed

+1280
-39
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"homepage": "https://github.com/vkalinichev/rutor-api",
1313
"main": "lib/index.js",
1414
"dependencies": {
15+
"ava": "^0.17.0",
1516
"cheerio": "^0.22.0",
1617
"request": "^2.79.0"
1718
},
@@ -26,7 +27,7 @@
2627
"build": "babel src -d lib",
2728
"prepublish": "npm run build && npm test",
2829
"lint": " eslint lib/*.js",
29-
"test": "echo \"Error: no test specified\" && exit 1"
30+
"test": "ava"
3031
},
3132
"engines": {
3233
"node": ">=4"

src/index.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { test } = require( 'ava' )
2+
const { config } = require( '.' )
3+
4+
test( 'Default config loaded', t => {
5+
const actual = config( {} )
6+
const expected = {
7+
base: 'http://tor-ru.net/search/',
8+
page: 0,
9+
category: 0,
10+
method: 100,
11+
order: 0
12+
}
13+
t.deepEqual( actual, expected )
14+
} )
15+
16+
test( 'Explicit config overrides defaults', t => {
17+
const actual = config( { base: 'http://rutor.org/search/' } )
18+
const expected = {
19+
base: 'http://rutor.org/search/',
20+
page: 0,
21+
category: 0,
22+
method: 100,
23+
order: 0
24+
}
25+
t.deepEqual( actual, expected )
26+
} )
27+

0 commit comments

Comments
 (0)