Bladeren bron

Add test case for #90

Ben Hsieh 8 jaren geleden
bovenliggende
commit
6c08ed738c
1 gewijzigde bestanden met toevoegingen van 23 en 0 verwijderingen
  1. 23
    0
      test/test-0.9.2.js

+ 23
- 0
test/test-0.9.2.js Bestand weergeven

@@ -103,3 +103,26 @@ describe('Upload multipart/form-data', (report, done) => {
103 103
     done()
104 104
   })
105 105
 })
106
+
107
+describe('app should not crash when sending formdata without data field', (report, done) => {
108
+
109
+  RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
110
+      Authorization : "Bearer fsXcpmKPrHgAAAAAAAAAEGxFXwhejXM_E8fznZoXPhHbhbNhA-Lytbe6etp1Jznz",
111
+      'Content-Type' : 'multipart/form-data',
112
+    }, [
113
+      { name : 'empty-file', filename : 'test-img.png'},
114
+      { name : 'empty-data'},
115
+      { name : 'field2', data : 'hello2 !!'}
116
+    ])
117
+  .then((resp) => {
118
+    console.log(resp.json())
119
+    resp = resp.json()
120
+
121
+    report(
122
+      <Assert key="check posted form data #1" expect={undefined} actual={resp.fields['empty-file']}/>,
123
+      <Assert key="check posted form data #2" expect={undefined} actual={resp.fields['empty-data']}/>,
124
+      <Assert key="check posted form data #3" expect="hello2 !!" actual={resp.fields.field2}/>,
125
+    )
126
+    done()
127
+  })
128
+})