From 91515d30bd6edba4e4b6306bb446cf19fe67f5eb Mon Sep 17 00:00:00 2001 From: Sefa Ilkimen Date: Mon, 3 Sep 2018 14:18:22 +0200 Subject: [PATCH] add test for gzipped content --- package.json | 6 +++--- test/app-test-definitions.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a573d64..7db2343 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,9 @@ "scripts": { "updatecert": "node ./scripts/update-test-cert.js", "buildbrowser": "./scripts/build-test-app.sh --browser", - "testandroid": "./scripts/build-test-app.sh --android --emulator && ./scripts/test-app.sh --android --emulator", - "testios": "./scripts/build-test-app.sh --ios --emulator && ./scripts/test-app.sh --ios --emulator", - "testapp": "npm run updatecert && npm run testandroid && npm run testios", + "testandroid": "npm run updatecert && ./scripts/build-test-app.sh --android --emulator && ./scripts/test-app.sh --android --emulator", + "testios": "npm run updatecert && ./scripts/build-test-app.sh --ios --emulator && ./scripts/test-app.sh --ios --emulator", + "testapp": "npm run testandroid && npm run testios", "testjs": "mocha ./test/js-mocha-specs.js", "test": "npm run testjs && npm run testapp", "release": "npm run test && ./scripts/release.sh" diff --git a/test/app-test-definitions.js b/test/app-test-definitions.js index 62a2de7..dd683e3 100644 --- a/test/app-test-definitions.js +++ b/test/app-test-definitions.js @@ -435,6 +435,7 @@ const tests = [ }, validationFunc: function(driver, result) { result.type.should.be.equal('resolved'); + result.data.status.should.be.equal(200); } },{ description: 'should reject when pinned cert does not match received server cert (GET)', @@ -474,6 +475,15 @@ const tests = [ result.data.status.should.be.equal(403); result.data.error.should.be.equal('There was an error downloading the file'); } + },{ + description: 'should handle gzip encoded response correctly', + expected: 'resolved: {"status": 200, "headers": "{\\"Content-Encoding\\": \\"gzip\\" ...', + func: function(resolve, reject) { cordova.plugin.http.get('http://httpbin.org/gzip', {}, {}, resolve, reject); }, + validationFunc: function(driver, result) { + result.type.should.be.equal('resolved'); + result.data.status.should.be.equal(200); + JSON.parse(result.data.data).gzipped.should.be.equal(true); + } } ];