test: implement e2e test for #301

This commit is contained in:
Sefa Ilkimen 2020-02-03 01:30:28 +01:00
parent b6f369b868
commit c88d1b6cc7
No known key found for this signature in database
GPG Key ID: 4AB0B60A9B5E59F5

View File

@ -3,7 +3,7 @@ const hooks = {
cordova.plugin.http.clearCookies();
helpers.enableFollowingRedirect(function() {
// server trust mode is not supported on brpwser platform
// server trust mode is not supported on browser platform
if (cordova.platformId === 'browser') {
return resolve();
}
@ -890,6 +890,39 @@ const tests = [
result.data.headers['access-control-allow-origin'].should.be.equal('*');
}
},
{
description: 'should decode JSON data correctly when response type is "json" #301',
expected: 'resolved: {"status":200,"data":{"slideshow": ... ',
func: function (resolve, reject) {
var url = 'https://httpbin.org/json';
var options = { method: 'get', responseType: 'json' };
cordova.plugin.http.sendRequest(url, options, resolve, reject);
},
validationFunc: function (driver, result) {
result.type.should.be.equal('resolved');
result.data.status.should.be.equal(200);
result.data.data.should.be.an('object');
result.data.data.slideshow.should.be.eql({
author: 'Yours Truly',
date: 'date of publication',
slides: [
{
title: 'Wake up to WonderWidgets!',
type: 'all'
},
{
items: [
'Why <em>WonderWidgets</em> are great',
'Who <em>buys</em> WonderWidgets'
],
title: 'Overview',
type: 'all'
}
],
title: 'Sample Slide Show'
});
}
},
// TODO: not ready yet
// {