Skip to content

Commit c88d1b6

Browse files
committed
test: implement e2e test for silkimen#301
1 parent b6f369b commit c88d1b6

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

test/e2e-specs.js

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const hooks = {
33
cordova.plugin.http.clearCookies();
44

55
helpers.enableFollowingRedirect(function() {
6-
// server trust mode is not supported on brpwser platform
6+
// server trust mode is not supported on browser platform
77
if (cordova.platformId === 'browser') {
88
return resolve();
99
}
@@ -787,7 +787,7 @@ const tests = [
787787
},
788788
{
789789
description: 'should decode error body even if response type is "arraybuffer"',
790-
expected: 'rejected: {"status": 418, ...',
790+
expected: 'rejected: {"status":418, ...',
791791
func: function (resolve, reject) {
792792
var url = 'https://httpbin.org/status/418';
793793
var options = { method: 'get', responseType: 'arraybuffer' };
@@ -801,7 +801,7 @@ const tests = [
801801
},
802802
{
803803
description: 'should serialize FormData instance correctly when it contains string value',
804-
expected: 'resolved: {"status": 200, ...',
804+
expected: 'resolved: {"status":200, ...',
805805
before: helpers.setMultipartSerializer,
806806
func: function (resolve, reject) {
807807
var ponyfills = cordova.plugin.http.ponyfills;
@@ -820,7 +820,7 @@ const tests = [
820820
},
821821
{
822822
description: 'should serialize FormData instance correctly when it contains blob value',
823-
expected: 'resolved: {"status": 200, ...',
823+
expected: 'resolved: {"status":200, ...',
824824
before: helpers.setMultipartSerializer,
825825
func: function (resolve, reject) {
826826
var ponyfills = cordova.plugin.http.ponyfills;
@@ -890,6 +890,39 @@ const tests = [
890890
result.data.headers['access-control-allow-origin'].should.be.equal('*');
891891
}
892892
},
893+
{
894+
description: 'should decode JSON data correctly when response type is "json" #301',
895+
expected: 'resolved: {"status":200,"data":{"slideshow": ... ',
896+
func: function (resolve, reject) {
897+
var url = 'https://httpbin.org/json';
898+
var options = { method: 'get', responseType: 'json' };
899+
cordova.plugin.http.sendRequest(url, options, resolve, reject);
900+
},
901+
validationFunc: function (driver, result) {
902+
result.type.should.be.equal('resolved');
903+
result.data.status.should.be.equal(200);
904+
result.data.data.should.be.an('object');
905+
result.data.data.slideshow.should.be.eql({
906+
author: 'Yours Truly',
907+
date: 'date of publication',
908+
slides: [
909+
{
910+
title: 'Wake up to WonderWidgets!',
911+
type: 'all'
912+
},
913+
{
914+
items: [
915+
'Why <em>WonderWidgets</em> are great',
916+
'Who <em>buys</em> WonderWidgets'
917+
],
918+
title: 'Overview',
919+
type: 'all'
920+
}
921+
],
922+
title: 'Sample Slide Show'
923+
});
924+
}
925+
},
893926

894927
// TODO: not ready yet
895928
// {

0 commit comments

Comments
 (0)