Skip to content

Commit

Permalink
Add tests for blue-tape & axios (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjaques authored and Flet committed Nov 14, 2017
1 parent 983416e commit c908641
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"url": "https://github.com/Flet/tape-nock/issues"
},
"devDependencies": {
"axios": "^0.17.1",
"blue-tape": "^1.0.0",
"coveralls": "^2.13.0",
"nyc": "^10.2.0",
"request": "^2.69.0",
Expand Down
62 changes: 62 additions & 0 deletions test/fixtures/it works with an axios based request_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[
{
"scope": "http://registry.npmjs.org:80",
"method": "get",
"path": "/",
"body": "",
"status": 200,
"response": {
"db_name": "registry",
"doc_count": 715027,
"doc_del_count": 344,
"update_seq": 725626,
"purge_seq": 0,
"compact_running": false,
"disk_size": 5895479523,
"other": {
"data_size": 17587744400
},
"data_size": 4075458684,
"sizes": {
"file": 5895479523,
"active": 4075458684,
"external": 17587744400
},
"instance_start_time": "1510677724009214",
"disk_format_version": 6,
"committed_update_seq": 725626,
"compacted_seq": 0,
"uuid": "394cafa300c4e4a5a9be8a9e16f637de"
},
"rawHeaders": [
"server",
"CouchDB/2.1.1 (Erlang OTP/R16B03)",
"Content-Type",
"application/json",
"Cache-Control",
"max-age=300",
"Content-Length",
"425",
"Accept-Ranges",
"bytes",
"Date",
"Tue, 14 Nov 2017 22:31:30 GMT",
"Via",
"1.1 varnish",
"Age",
"88",
"Connection",
"close",
"X-Served-By",
"cache-mdw17351-MDW",
"X-Cache",
"HIT",
"X-Cache-Hits",
"1",
"X-Timer",
"S1510698691.588226,VS0,VE0",
"Vary",
"Accept-Encoding, Accept"
]
}
]
23 changes: 23 additions & 0 deletions test/promise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

var request = require('axios')

var tape = require('blue-tape')

var test = require('../')(tape)

test('it works with a plain promise', function (t) {
return timeout(100).then(function () {
t.assert(true, 'assertion is made')
})
})

test('it works with an axios based request', function (t) {
return request('http://registry.npmjs.org')
.then(function (resp) {
t.equal(resp.status, 200)
})
})

function timeout (ms) {
return new Promise(function (resolve) { setTimeout(resolve, ms) })
}

0 comments on commit c908641

Please sign in to comment.