diff --git a/test/app-test-definitions.js b/test/app-test-definitions.js index de8c46e..0a0ac0e 100644 --- a/test/app-test-definitions.js +++ b/test/app-test-definitions.js @@ -1,5 +1,6 @@ const hooks = { onBeforeEachTest: function(done) { + cordova.plugin.http.clearCookies(); cordova.plugin.http.acceptAllCerts(false, done, done); } }; @@ -312,6 +313,24 @@ const tests = [ result.type.should.be.equal('resolved'); 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'); + } } ];