Merge pull request #2390 from NativeScript/jasssonpet/fetch-tests

Remove unused result variables in fetch tests
This commit is contained in:
Jason Zhekov
2016-06-30 16:35:44 +03:00
committed by GitHub

View File

@ -7,12 +7,11 @@ export var test_fetch_defined = function () {
}; };
export var test_fetch = function (done: (err: Error, res?: string) => void) { export var test_fetch = function (done: (err: Error, res?: string) => void) {
var result;
// >> fetch-response // >> fetch-response
fetch("https://httpbin.org/get").then(function (r) { fetch("https://httpbin.org/get").then(function (r) {
// Argument (r) is Response! // Argument (r) is Response!
// >> (hide) // >> (hide)
TKUnit.assert(r instanceof Response, "Result from fetch() should be valid Response object! Actual result is: " + result); TKUnit.assert(r instanceof Response, "Result from fetch() should be valid Response object! Actual result is: " + r);
done(null); done(null);
// << (hide) // << (hide)
}, function (e) { }, function (e) {
@ -25,8 +24,6 @@ export var test_fetch = function (done: (err: Error, res?: string) => void) {
}; };
export var test_fetch_text = function (done: (err: Error, res?: string) => void) { export var test_fetch_text = function (done: (err: Error, res?: string) => void) {
var result;
// >> fetch-string' // >> fetch-string'
fetch("https://httpbin.org/get").then(response => { return response.text(); }).then(function (r) { fetch("https://httpbin.org/get").then(response => { return response.text(); }).then(function (r) {
// Argument (r) is string! // Argument (r) is string!
@ -44,8 +41,6 @@ export var test_fetch_text = function (done: (err: Error, res?: string) => void)
}; };
export var test_fetch_json = function (done: (err: Error, res?: string) => void) { export var test_fetch_json = function (done: (err: Error, res?: string) => void) {
var result;
// >> fetch-json // >> fetch-json
fetch("https://httpbin.org/get").then(response => { return response.json(); }).then(function (r) { fetch("https://httpbin.org/get").then(response => { return response.json(); }).then(function (r) {
// Argument (r) is JSON object! // Argument (r) is JSON object!
@ -63,8 +58,6 @@ export var test_fetch_json = function (done: (err: Error, res?: string) => void)
}; };
export var test_fetch_formData = function (done: (err: Error, res?: string) => void) { export var test_fetch_formData = function (done: (err: Error, res?: string) => void) {
var result;
// >> fetch-formdata // >> fetch-formdata
fetch("https://httpbin.org/get").then(response => { return response.formData(); }).then(function (r) { fetch("https://httpbin.org/get").then(response => { return response.formData(); }).then(function (r) {
// Argument (r) is FormData object! // Argument (r) is FormData object!
@ -140,13 +133,11 @@ export var test_fetch_response_headers = function (done) {
}; };
export var test_fetch_headers_sent = function (done) { export var test_fetch_headers_sent = function (done) {
var result: Headers;
fetch("https://httpbin.org/get", { fetch("https://httpbin.org/get", {
method: "GET", method: "GET",
headers: { "Content-Type": "application/json" } headers: { "Content-Type": "application/json" }
}).then(function (response) { }).then(function (response) {
result = response.headers; var result = response.headers;
try { try {
TKUnit.assert(result.get("Content-Type") === "application/json", "Headers not sent/received properly! Actual result is: " + result); TKUnit.assert(result.get("Content-Type") === "application/json", "Headers not sent/received properly! Actual result is: " + result);
done(null); done(null);