added test cases for regex
This commit is contained in:
parent
b417f0d2ba
commit
3f59e6e964
|
@ -5,7 +5,11 @@ Changelog
|
|||
|
||||
# 1.x release
|
||||
|
||||
## v1.0.5 (master)
|
||||
## v1.0.6 (master)
|
||||
|
||||
- Fix: less greedy content-type charset matching
|
||||
|
||||
## v1.0.5
|
||||
|
||||
- Fix: when follow = 0, fetch should not follow redirect
|
||||
- Enhance: update tests for better coverage
|
||||
|
|
|
@ -139,6 +139,18 @@ TestServer.prototype.router = function(req, res) {
|
|||
res.end('中文');
|
||||
}
|
||||
|
||||
if (p === '/encoding/order1') {
|
||||
res.statusCode = 200;
|
||||
res.setHeader('Content-Type', 'charset=gbk; text/plain');
|
||||
res.end(convert('中文', 'gbk'));
|
||||
}
|
||||
|
||||
if (p === '/encoding/order2') {
|
||||
res.statusCode = 200;
|
||||
res.setHeader('Content-Type', 'text/plain; charset=gbk; qs=1');
|
||||
res.end(convert('中文', 'gbk'));
|
||||
}
|
||||
|
||||
if (p === '/redirect/301') {
|
||||
res.statusCode = 301;
|
||||
res.setHeader('Location', '/inspect');
|
||||
|
|
20
test/test.js
20
test/test.js
|
@ -502,6 +502,26 @@ describe('node-fetch', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should support uncommon content-type order, charset in front', function() {
|
||||
url = base + '/encoding/order1';
|
||||
return fetch(url).then(function(res) {
|
||||
expect(res.status).to.equal(200);
|
||||
return res.text().then(function(result) {
|
||||
expect(result).to.equal('中文');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should support uncommon content-type order, end with qs', function() {
|
||||
url = base + '/encoding/order2';
|
||||
return fetch(url).then(function(res) {
|
||||
expect(res.status).to.equal(200);
|
||||
return res.text().then(function(result) {
|
||||
expect(result).to.equal('中文');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow piping response body as stream', function(done) {
|
||||
url = base + '/hello';
|
||||
fetch(url).then(function(res) {
|
||||
|
|
Loading…
Reference in New Issue