Skip to content

Commit 86698ff

Browse files
author
Sefa Ilkimen
committed
add a spec to ensure empty body strings are handled correctly (not throwing an decoder error)
1 parent 4a396c2 commit 86698ff

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/app-test-definitions.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ const tests = [
392392
},
393393
validationFunc: function(driver, result) {
394394
result.type.should.be.equal('resolved');
395-
JSON.parse(result.data.data).data.should.eql('this is a test string');
395+
JSON.parse(result.data.data).data.should.be.equal('this is a test string');
396396
}
397397
},{
398398
description: 'should encode spaces in query string (params object) correctly (GET) #71',
@@ -402,7 +402,7 @@ const tests = [
402402
},
403403
validationFunc: function(driver, result) {
404404
result.type.should.be.equal('resolved');
405-
JSON.parse(result.data.data).args['query param'].should.eql('and value with spaces');
405+
JSON.parse(result.data.data).args['query param'].should.be.equal('and value with spaces');
406406
}
407407
},{
408408
description: 'should decode latin1 (iso-8859-1) encoded body correctly (GET) #72',
@@ -414,6 +414,16 @@ const tests = [
414414
result.type.should.be.equal('resolved');
415415
result.data.data.should.include('[¡] 161 10/01 241 A1 INVERTED EXCLAMATION MARK\n[¢] 162 10/02 242 A2 CENT SIGN');
416416
}
417+
},{
418+
description: 'should return empty body string correctly (GET)',
419+
expected: 'resolved: {"status": 200, "data": "" ...',
420+
func: function(resolve, reject) {
421+
cordova.plugin.http.get('http://httpbin.org/stream/0', {}, {}, resolve, reject);
422+
},
423+
validationFunc: function(driver, result) {
424+
result.type.should.be.equal('resolved');
425+
result.data.data.should.be.equal('');
426+
}
417427
}
418428
];
419429

0 commit comments

Comments
 (0)