WIP commit for iOS:

- failure handler gets called if an exception occurs in native code
- rename "raw" serializer to "utf8"
- extract serializer into separate file
This commit is contained in:
Sefa Ilkimen
2018-02-07 16:31:51 +01:00
parent 60e7debbdf
commit c452b29433
9 changed files with 289 additions and 234 deletions
+12
View File
@@ -8,6 +8,7 @@ const hooks = {
const helpers = {
acceptAllCerts: function(done) { cordova.plugin.http.acceptAllCerts(true, done, done); },
setJsonSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('json')); },
setUtf8StringSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('utf8')); },
setUrlEncodedSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('urlencoded')); },
getWithXhr: function(done, url) {
var xhr = new XMLHttpRequest();
@@ -382,6 +383,17 @@ const tests = [
cookies.myCookie.should.be.equal('myValue');
cookies.mySecondCookie.should.be.equal('mySecondValue');
}
},{
description: 'should send UTF-8 encoded raw string correctly (POST)',
expected: 'resolved: {"status": 200, "data": "{\\"data\\": \\"this is a test string\\"...',
before: helpers.setUtf8StringSerializer,
func: function(resolve, reject) {
cordova.plugin.http.post('http://httpbin.org/anything', { text: 'this is a test string' }, {}, resolve, reject);
},
validationFunc: function(driver, result) {
result.type.should.be.equal('resolved');
JSON.parse(result.data.data).data.should.eql('this is a test string');
}
}
];