Skip to content

Commit 419283c

Browse files
author
Sefa Ilkimen
committed
add another spec for cookie handling
1 parent 7a8f9a0 commit 419283c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/app-test-definitions.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,38 @@ const tests = [
331331
.Cookie
332332
.should.be.equal('myCookie=myValue; mySecondCookie=mySecondValue');
333333
}
334+
},{
335+
description: 'should send programmatically set cookies correctly (DOWNLOAD) #57',
336+
expected: 'resolved: {"content":{"cookies":{"myCookie":"myValue ...',
337+
func: function(resolve, reject) {
338+
var sourceUrl = 'http://httpbin.org/cookies';
339+
var targetPath = cordova.file.cacheDirectory + 'cookies.json';
340+
341+
cordova.plugin.http.setCookie('http://httpbin.org/get', 'myCookie=myValue');
342+
cordova.plugin.http.setCookie('http://httpbin.org/get', 'mySecondCookie=mySecondValue');
343+
344+
cordova.plugin.http.downloadFile(sourceUrl, {}, {}, targetPath, function(entry) {
345+
helpers.getWithXhr(function(content) {
346+
resolve({
347+
sourceUrl: sourceUrl,
348+
targetPath: targetPath,
349+
fullPath: entry.fullPath,
350+
name: entry.name,
351+
content: content
352+
});
353+
}, targetPath);
354+
}, reject);
355+
},
356+
validationFunc: function(driver, result) {
357+
result.type.should.be.equal('resolved');
358+
result.data.name.should.be.equal('cookies.json');
359+
result.data.content.should.be.a('string');
360+
361+
var cookies = JSON.parse(result.data.content).cookies;
362+
363+
cookies.myCookie.should.be.equal('myValue');
364+
cookies.mySecondCookie.should.be.equal('mySecondValue');
365+
}
334366
}
335367
];
336368

0 commit comments

Comments
 (0)