cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject spec commit: CB-6657 - 3 FileTransfer tests have false negatives
Date Thu, 08 May 2014 19:41:44 GMT
Repository: cordova-mobile-spec
Updated Branches:
  refs/heads/master 9c8e366c2 -> 2246995ca


CB-6657 - 3 FileTransfer tests have false negatives


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/2246995c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/2246995c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/2246995c

Branch: refs/heads/master
Commit: 2246995ca81e2a3575087fc39875d06158465514
Parents: 9c8e366
Author: Shazron Abdullah <shazron@apache.org>
Authored: Thu May 8 12:40:41 2014 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Thu May 8 12:40:41 2014 -0700

----------------------------------------------------------------------
 autotest/tests/filetransfer.tests.js | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/2246995c/autotest/tests/filetransfer.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/filetransfer.tests.js b/autotest/tests/filetransfer.tests.js
index dc95513..cbe15c0 100644
--- a/autotest/tests/filetransfer.tests.js
+++ b/autotest/tests/filetransfer.tests.js
@@ -459,7 +459,15 @@ describe('FileTransfer', function() {
             var uploadWin = jasmine.createSpy().andCallFake(function(uploadResult) {
                 expect(uploadResult.bytesSent).toBeGreaterThan(0);
                 expect(uploadResult.responseCode).toBe(200);
-                expect(uploadResult.response).toMatch(/fields:\s*{\s*value1.*/);
+                var obj = null;
+                try {
+                    obj = JSON.parse(uploadResult.response);
+                    expect(obj.fields).toBeDefined();
+                    expect(obj.fields.value1).toBe("test");
+                    expect(obj.fields.value2).toBe("param");
+                } catch (e) {
+                    expect(obj).not.toBeNull('returned data from server should be valid json');
+                }
                 expect(lastProgressEvent).not.toBeNull('expected progress events');
                 if (cordova.platformId == 'ios') {
                     expect(uploadResult.headers && uploadResult.headers['Content-Type']).toBeDefined('Expected
content-type header to be defined.');
@@ -512,7 +520,15 @@ describe('FileTransfer', function() {
             var uploadWin = jasmine.createSpy().andCallFake(function(uploadResult) {
                 expect(uploadResult.bytesSent).toBeGreaterThan(0);
                 expect(uploadResult.responseCode).toBe(200);
-                expect(uploadResult.response).toMatch(/fields:\s*{\s*value1.*/);
+                var obj = null;
+                try {
+                    obj = JSON.parse(uploadResult.response);
+                    expect(obj.fields).toBeDefined();
+                    expect(obj.fields.value1).toBe("test");
+                    expect(obj.fields.value2).toBe("param");
+                } catch (e) {
+                    expect(obj).not.toBeNull('returned data from server should be valid json');
+                }
             });
 
             var fileWin = function(fileEntry) {
@@ -840,7 +856,15 @@ describe('FileTransfer', function() {
             var uploadWin = jasmine.createSpy().andCallFake(function(uploadResult) {
                 expect(uploadResult.bytesSent).toBeGreaterThan(0);
                 expect(uploadResult.responseCode).toBe(200);
-                expect(uploadResult.response).toMatch(/fields:\s*{\s*value1.*/);
+                var obj = null;
+                try {
+                    obj = JSON.parse(uploadResult.response);
+                    expect(obj.fields).toBeDefined();
+                    expect(obj.fields.value1).toBe("test");
+                    expect(obj.fields.value2).toBe("param");
+                } catch (e) {
+                    expect(obj).not.toBeNull('returned data from server should be valid json');
+                }
             });
 
             var fileWin = function(fileEntry) {


Mime
View raw message