mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
test: use our own http-echo server (#10227)
This commit is contained in:
@@ -8,7 +8,7 @@ export var test_fetch_defined = function () {
|
||||
|
||||
export var test_fetch = function (done: (err: Error, res?: string) => void) {
|
||||
// >> fetch-response
|
||||
fetch('https://httpbin.org/get')
|
||||
fetch('https://http-echo.nativescript.org/get')
|
||||
.then(function (r) {
|
||||
// Argument (r) is Response!
|
||||
// >> (hide)
|
||||
@@ -22,7 +22,7 @@ export var test_fetch = function (done: (err: Error, res?: string) => void) {
|
||||
|
||||
export var test_fetch_text = function (done: (err: Error, res?: string) => void) {
|
||||
// >> fetch-string
|
||||
fetch('https://httpbin.org/get')
|
||||
fetch('https://http-echo.nativescript.org/get')
|
||||
.then((response) => response.text())
|
||||
.then(function (r) {
|
||||
// Argument (r) is string!
|
||||
@@ -37,7 +37,7 @@ export var test_fetch_text = function (done: (err: Error, res?: string) => void)
|
||||
|
||||
export var test_fetch_json = function (done: (err: Error, res?: string) => void) {
|
||||
// >> fetch-json
|
||||
fetch('https://httpbin.org/get')
|
||||
fetch('https://http-echo.nativescript.org/get')
|
||||
.then((response) => response.json())
|
||||
.then(function (r) {
|
||||
// Argument (r) is JSON object!
|
||||
@@ -52,7 +52,7 @@ export var test_fetch_json = function (done: (err: Error, res?: string) => void)
|
||||
|
||||
export var test_fetch_formData = function (done: (err: Error, res?: string) => void) {
|
||||
// >> fetch-formdata
|
||||
fetch('https://httpbin.org/get')
|
||||
fetch('https://http-echo.nativescript.org/get')
|
||||
.then((response) => response.formData())
|
||||
.then(function (r) {
|
||||
// Argument (r) is FormData object!
|
||||
@@ -67,7 +67,7 @@ export var test_fetch_formData = function (done: (err: Error, res?: string) => v
|
||||
|
||||
export var test_fetch_blob = function (done: (err: Error, res?: string) => void) {
|
||||
// >> fetch-blob
|
||||
fetch('https://httpbin.org/get')
|
||||
fetch('https://http-echo.nativescript.org/get')
|
||||
.then((response) => response.blob())
|
||||
.then(function (r) {
|
||||
// Argument (r) is Blob object!
|
||||
@@ -82,7 +82,7 @@ export var test_fetch_blob = function (done: (err: Error, res?: string) => void)
|
||||
|
||||
export var test_fetch_arraybuffer = function (done: (err: Error, res?: string) => void) {
|
||||
// >> fetch-arraybuffer
|
||||
fetch('https://httpbin.org/get')
|
||||
fetch('https://http-echo.nativescript.org/get')
|
||||
.then((response) => response.arrayBuffer())
|
||||
.then(function (r) {
|
||||
// Argument (r) is ArrayBuffer object!
|
||||
@@ -101,7 +101,7 @@ export var test_fetch_fail_invalid_url = function (done) {
|
||||
return completed;
|
||||
};
|
||||
|
||||
fetch('hgfttp://httpbin.org/get')
|
||||
fetch('hgfttp://http-echo.nativescript.org/get')
|
||||
.catch(function (e) {
|
||||
completed = true;
|
||||
done(null);
|
||||
@@ -111,7 +111,7 @@ export var test_fetch_fail_invalid_url = function (done) {
|
||||
|
||||
// Note: fetch is unable to do url validation
|
||||
// export var test_fetch_invalid_url_fail_message = function (done) {
|
||||
// fetch("hgfttp://httpbin.org/get").catch(function (e: TypeError) {
|
||||
// fetch("hgfttp://http-echo.nativescript.org/get").catch(function (e: TypeError) {
|
||||
// TKUnit.assert(e.message.match(/Network request failed:.{2,}/), "Failure message should contain details on the failure. Actual message was: " + e.message);
|
||||
// done(null);
|
||||
// }).catch(failOnError(done));
|
||||
@@ -119,7 +119,7 @@ export var test_fetch_fail_invalid_url = function (done) {
|
||||
|
||||
export var test_fetch_response_status = function (done) {
|
||||
// >> fetch-status-response
|
||||
fetch('https://httpbin.org/get')
|
||||
fetch('https://http-echo.nativescript.org/get')
|
||||
.then(function (response) {
|
||||
// Argument (response) is Response!
|
||||
var statusCode = response.status;
|
||||
@@ -134,7 +134,7 @@ export var test_fetch_response_status = function (done) {
|
||||
|
||||
export var test_fetch_response_headers = function (done) {
|
||||
// >> fetch-headers-response
|
||||
fetch('https://httpbin.org/get')
|
||||
fetch('https://http-echo.nativescript.org/get')
|
||||
.then(function (response) {
|
||||
// Argument (response) is Response!
|
||||
// var all = response.headers.getAll();
|
||||
@@ -148,7 +148,7 @@ export var test_fetch_response_headers = function (done) {
|
||||
};
|
||||
|
||||
export var test_fetch_headers_sent = function (done) {
|
||||
fetch('https://httpbin.org/get', {
|
||||
fetch('https://http-echo.nativescript.org/get', {
|
||||
method: 'GET',
|
||||
headers: new Headers({ 'Content-Type': 'application/json' }),
|
||||
})
|
||||
@@ -165,7 +165,7 @@ export var test_fetch_post_form_data = function (done) {
|
||||
data.append('MyVariableOne', 'ValueOne');
|
||||
data.append('MyVariableTwo', 'ValueTwo');
|
||||
|
||||
fetch('https://httpbin.org/post', {
|
||||
fetch('https://http-echo.nativescript.org/post', {
|
||||
method: 'POST',
|
||||
headers: new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' }),
|
||||
body: data,
|
||||
@@ -182,7 +182,7 @@ export var test_fetch_post_form_data = function (done) {
|
||||
|
||||
export var test_fetch_post_json = function (done) {
|
||||
// >> fetch-post-json
|
||||
fetch('https://httpbin.org/post', {
|
||||
fetch('https://http-echo.nativescript.org/post', {
|
||||
method: 'POST',
|
||||
headers: new Headers({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify({ MyVariableOne: 'ValueOne', MyVariableTwo: 'ValueTwo' }),
|
||||
|
||||
Reference in New Issue
Block a user