Skip to content

Commit 7a8f9a0

Browse files
author
Sefa Ilkimen
committed
add a spec for cookie handling
1 parent 64731a3 commit 7a8f9a0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/app-test-definitions.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const hooks = {
22
onBeforeEachTest: function(done) {
3+
cordova.plugin.http.clearCookies();
34
cordova.plugin.http.acceptAllCerts(false, done, done);
45
}
56
};
@@ -312,6 +313,24 @@ const tests = [
312313
result.type.should.be.equal('resolved');
313314
result.data.status.should.be.equal(200);
314315
}
316+
},{
317+
description: 'should send programmatically set cookies correctly (GET)',
318+
expected: 'resolved: {"status": 200, ...',
319+
func: function(resolve, reject) {
320+
cordova.plugin.http.setCookie('http://httpbin.org/get', 'myCookie=myValue');
321+
cordova.plugin.http.setCookie('http://httpbin.org/get', 'mySecondCookie=mySecondValue');
322+
cordova.plugin.http.get('http://httpbin.org/get', {}, {}, resolve, reject);
323+
},
324+
validationFunc: function(driver, result) {
325+
result.type.should.be.equal('resolved');
326+
result.data.data.should.be.a('string');
327+
328+
JSON
329+
.parse(result.data.data)
330+
.headers
331+
.Cookie
332+
.should.be.equal('myCookie=myValue; mySecondCookie=mySecondValue');
333+
}
315334
}
316335
];
317336

0 commit comments

Comments
 (0)