demostrate restream more clearly in tests
This commit is contained in:
parent
89ce1b70b6
commit
4d63427123
21
test/test.js
21
test/test.js
|
@ -800,13 +800,26 @@ describe('node-fetch', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should allow cloning a json response, and log it as text response', function() {
|
||||
it('should allow cloning a json response and log it as text response', function() {
|
||||
url = base + '/json';
|
||||
return fetch(url).then(function(res) {
|
||||
var r1 = res.clone();
|
||||
return fetch.Promise.all([r1.text(), res.json()]).then(function(results) {
|
||||
expect(results[0]).to.equal('{"name":"value"}');
|
||||
expect(results[1]).to.deep.equal({name: 'value'});
|
||||
return fetch.Promise.all([res.json(), r1.text()]).then(function(results) {
|
||||
expect(results[0]).to.deep.equal({name: 'value'});
|
||||
expect(results[1]).to.equal('{"name":"value"}');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow cloning a json response, and then log it as text response', function() {
|
||||
url = base + '/json';
|
||||
return fetch(url).then(function(res) {
|
||||
var r1 = res.clone();
|
||||
return res.json().then(function(result) {
|
||||
expect(result).to.deep.equal({name: 'value'});
|
||||
return r1.text().then(function(result) {
|
||||
expect(result).to.equal('{"name":"value"}');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue