mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2024-10-06 09:12:13 +08:00
test: implement e2e test for #301
This commit is contained in:
parent
b6f369b868
commit
c88d1b6cc7
@ -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();
|
||||
}
|
||||
@ -787,7 +787,7 @@ const tests = [
|
||||
},
|
||||
{
|
||||
description: 'should decode error body even if response type is "arraybuffer"',
|
||||
expected: 'rejected: {"status": 418, ...',
|
||||
expected: 'rejected: {"status":418, ...',
|
||||
func: function (resolve, reject) {
|
||||
var url = 'https://httpbin.org/status/418';
|
||||
var options = { method: 'get', responseType: 'arraybuffer' };
|
||||
@ -801,7 +801,7 @@ const tests = [
|
||||
},
|
||||
{
|
||||
description: 'should serialize FormData instance correctly when it contains string value',
|
||||
expected: 'resolved: {"status": 200, ...',
|
||||
expected: 'resolved: {"status":200, ...',
|
||||
before: helpers.setMultipartSerializer,
|
||||
func: function (resolve, reject) {
|
||||
var ponyfills = cordova.plugin.http.ponyfills;
|
||||
@ -820,7 +820,7 @@ const tests = [
|
||||
},
|
||||
{
|
||||
description: 'should serialize FormData instance correctly when it contains blob value',
|
||||
expected: 'resolved: {"status": 200, ...',
|
||||
expected: 'resolved: {"status":200, ...',
|
||||
before: helpers.setMultipartSerializer,
|
||||
func: function (resolve, reject) {
|
||||
var ponyfills = cordova.plugin.http.ponyfills;
|
||||
@ -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
|
||||
// {
|
||||
|
Loading…
Reference in New Issue
Block a user