mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2024-10-07 01:32:12 +08:00
add a spec for cookie handling
This commit is contained in:
parent
64731a3794
commit
7a8f9a0dba
@ -1,5 +1,6 @@
|
|||||||
const hooks = {
|
const hooks = {
|
||||||
onBeforeEachTest: function(done) {
|
onBeforeEachTest: function(done) {
|
||||||
|
cordova.plugin.http.clearCookies();
|
||||||
cordova.plugin.http.acceptAllCerts(false, done, done);
|
cordova.plugin.http.acceptAllCerts(false, done, done);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -312,6 +313,24 @@ const tests = [
|
|||||||
result.type.should.be.equal('resolved');
|
result.type.should.be.equal('resolved');
|
||||||
result.data.status.should.be.equal(200);
|
result.data.status.should.be.equal(200);
|
||||||
}
|
}
|
||||||
|
},{
|
||||||
|
description: 'should send programmatically set cookies correctly (GET)',
|
||||||
|
expected: 'resolved: {"status": 200, ...',
|
||||||
|
func: function(resolve, reject) {
|
||||||
|
cordova.plugin.http.setCookie('http://httpbin.org/get', 'myCookie=myValue');
|
||||||
|
cordova.plugin.http.setCookie('http://httpbin.org/get', 'mySecondCookie=mySecondValue');
|
||||||
|
cordova.plugin.http.get('http://httpbin.org/get', {}, {}, resolve, reject);
|
||||||
|
},
|
||||||
|
validationFunc: function(driver, result) {
|
||||||
|
result.type.should.be.equal('resolved');
|
||||||
|
result.data.data.should.be.a('string');
|
||||||
|
|
||||||
|
JSON
|
||||||
|
.parse(result.data.data)
|
||||||
|
.headers
|
||||||
|
.Cookie
|
||||||
|
.should.be.equal('myCookie=myValue; mySecondCookie=mySecondValue');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user