Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Update mocha timeouts to match expected HTTP timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
hildjj committed May 2, 2016
1 parent bec185b commit d6401bb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/index.test.js
Expand Up @@ -17,21 +17,25 @@ var fs = require('fs');
describe('urllib-sync', function () {
describe('request()', function () {
it('should request gbk ok', function () {
this.timeout(4000);
var res = urllib.request('http://www.taobao.com/go/rgn/tmall/header/2014/sub-nav.php');
var data = iconv.decode(res.data, 'gbk');
data.should.containEql('天猫');
res.status.should.equal(200);
});

it('should request text ok', function () {
this.timeout(30000);
var res = urllib.request('http://npm.taobao.org', {
dataType: 'text'
dataType: 'text',
timeout: 30000
});
res.data.should.containEql('淘宝 NPM 镜像');
res.status.should.equal(200);
});

it('should request json ok', function () {
this.timeout(30000);
var res = urllib.request('http://registry.npm.taobao.org/koa', {
dataType: 'json',
timeout: 30000
Expand All @@ -53,6 +57,7 @@ describe('urllib-sync', function () {
});

it('should writeFile ok', function () {
this.timeout(4000);
var res = urllib.request('http://www.taobao.com/go/rgn/tmall/header/2014/sub-nav.php', {
writeFile: './tmp'
});
Expand All @@ -63,6 +68,7 @@ describe('urllib-sync', function () {
});

it('should not write file when status 302', function () {
this.timeout(4000);
var res = urllib.request('http://www.taobao.com/not/exist/file/path', {
writeFile: './404file'
});
Expand Down

0 comments on commit d6401bb

Please sign in to comment.