Pārlūkot izejas kodu

correct test case setting

Ben Hsieh 8 gadus atpakaļ
vecāks
revīzija
ba5ca80f28
3 mainītis faili ar 126 papildinājumiem un 126 dzēšanām
  1. 118
    118
      test/test-0.6.2.js
  2. 1
    1
      test/test-0.6.3.js
  3. 7
    7
      test/test-init.js

+ 118
- 118
test/test-0.6.2.js Parādīt failu

@@ -55,124 +55,124 @@ describe('upload asset from camera roll', (report, done) => {
55 55
       done()
56 56
     })
57 57
 })
58
-//
59
-// describe('Upload multipart data with file from CameraRoll', (report, done) => {
60
-//     let filename = 'test-from-storage-img-'+Date.now()+'.png'
61
-//     RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
62
-//         'Content-Type' : 'multipart/form-data',
63
-//       }, [
64
-//         { name : 'test-img', filename : filename, data: RNFetchBlob.wrap(photo)},
65
-//         { name : 'test-text', filename : 'test-text.txt', data: RNFetchBlob.base64.encode('hello.txt')},
66
-//         { name : 'field1', data : 'hello !!'},
67
-//         { name : 'field2', data : 'hello2 !!'}
68
-//       ])
69
-//     .then((resp) => {
70
-//       resp = resp.json()
71
-//       report(
72
-//         <Assert key="check posted form data #1" expect="hello !!" actual={resp.fields.field1}/>,
73
-//         <Assert key="check posted form data #2" expect="hello2 !!" actual={resp.fields.field2}/>,
74
-//       )
75
-//       return RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/${filename}`)
76
-//     })
77
-//     .then((resp) => {
78
-//       report(<Info key="uploaded image">
79
-//         <Image
80
-//           style={styles.image}
81
-//           source={{ uri : 'data:image/png;base64, '+ resp.base64()}}/>
82
-//       </Info>)
83
-//       done()
84
-//     })
85
-// })
86
-//
87
-//
88
-// describe('access assets from camera roll', (report, done) => {
89
-//   let photo = null
90
-//   CameraRoll.getPhotos({first : 10})
91
-//     .then((resp) => {
92
-//       photo = resp.edges[0].node.image.uri
93
-//       report(<Info key="items">
94
-//         <Text>{photo}</Text>
95
-//       </Info>)
96
-//       return fs.readFile(photo, 'base64')
97
-//     })
98
-//     .then((data) => {
99
-//       report(<Info key="asset image">
100
-//         <Image
101
-//           style={styles.image}
102
-//           source={{uri: `data:image/png;base64, ${data}`}}/>
103
-//       </Info>)
104
-//       done()
105
-//     })
106
-// })
107
-//
108
-// describe('read asset in app bundle',(report, done) => {
109
-//   let target = fs.asset('test-asset2.png')
110
-//   fs.readFile(target, 'base64')
111
-//   .then((data) => {
112
-//     report(<Info key="asset image">
113
-//       <Image
114
-//         style={styles.image}
115
-//         source={{uri: `data:image/png;base64, ${data}`}}/>
116
-//     </Info>)
117
-//     return fs.readFile(fs.asset('test-asset1.json'), 'utf8')
118
-//   })
119
-//   .then((resp) => {
120
-//     report(
121
-//       <Assert key="asset content verify"
122
-//         expect="asset#1"
123
-//         actual={JSON.parse(resp).secret}/>)
124
-//       done()
125
-//   })
126
-// })
127
-//
128
-// describe('stat assets in app', (report, done) => {
129
-//   fs.stat(fs.asset('test-asset2.png'))
130
-//     .then((data) => {
131
-//       report(<Info key="list of assets">
132
-//         <Text>{JSON.stringify(data)}</Text>
133
-//       </Info>)
134
-//       done()
135
-//     })
136
-// })
137
-//
138
-// describe('copy asset', (report, done) => {
139
-//   let dest = `${dirs.DocumentDir}/test-asset-1-${Date.now()}.json`
140
-//   fs.cp(fs.asset('test-asset1.json'), dest)
141
-//     .then(() => fs.readFile(dest, 'utf8'))
142
-//     .then((data) => {
143
-//       report(<Assert key="asset copied correctly"
144
-//         expect={'asset#1'}
145
-//         actual={JSON.parse(data).secret}/>)
146
-//       return fs.stat(fs.asset('test-asset1.json'))
147
-//     })
148
-//     .then((stat) => {
149
-//       report(<Assert key="file size check"
150
-//         expect={27}
151
-//         actual={Math.floor(stat.size)}/>,
152
-//       <Info key="dest file info">
153
-//         <Text>{JSON.stringify(stat)}</Text>
154
-//       </Info>)
155
-//       done()
156
-//     })
157
-// })
158
-//
159
-//
160
-// describe('upload file from assets',(report, done) => {
161
-//   let assetName = fs.asset('test-asset1.json')
162
-//   RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
163
-//     Authorization : `Bearer ${DROPBOX_TOKEN}`,
164
-//     'Dropbox-API-Arg': `{\"path\": \"/rn-upload/file-from-asset-${Platform.OS}.json\",\"mode\": \"add\",\"autorename\": false,\"mute\": false}`,
165
-//     'Content-Type' : 'application/octet-stream',
166
-//   }, RNFetchBlob.wrap(assetName))
167
-//   .then((resp) => {
168
-//     resp = resp.json()
169
-//     report(
170
-//       <Assert key="file name check"
171
-//         expect={`file-from-asset-${Platform.OS}.json`}
172
-//         actual={resp.name}/>)
173
-//     done()
174
-//   })
175
-// })
58
+
59
+describe('Upload multipart data with file from CameraRoll', (report, done) => {
60
+    let filename = 'test-from-storage-img-'+Date.now()+'.png'
61
+    RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
62
+        'Content-Type' : 'multipart/form-data',
63
+      }, [
64
+        { name : 'test-img', filename : filename, data: RNFetchBlob.wrap(photo)},
65
+        { name : 'test-text', filename : 'test-text.txt', data: RNFetchBlob.base64.encode('hello.txt')},
66
+        { name : 'field1', data : 'hello !!'},
67
+        { name : 'field2', data : 'hello2 !!'}
68
+      ])
69
+    .then((resp) => {
70
+      resp = resp.json()
71
+      report(
72
+        <Assert key="check posted form data #1" expect="hello !!" actual={resp.fields.field1}/>,
73
+        <Assert key="check posted form data #2" expect="hello2 !!" actual={resp.fields.field2}/>,
74
+      )
75
+      return RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/${filename}`)
76
+    })
77
+    .then((resp) => {
78
+      report(<Info key="uploaded image">
79
+        <Image
80
+          style={styles.image}
81
+          source={{ uri : 'data:image/png;base64, '+ resp.base64()}}/>
82
+      </Info>)
83
+      done()
84
+    })
85
+})
86
+
87
+
88
+describe('access assets from camera roll', (report, done) => {
89
+  let photo = null
90
+  CameraRoll.getPhotos({first : 10})
91
+    .then((resp) => {
92
+      photo = resp.edges[0].node.image.uri
93
+      report(<Info key="items">
94
+        <Text>{photo}</Text>
95
+      </Info>)
96
+      return fs.readFile(photo, 'base64')
97
+    })
98
+    .then((data) => {
99
+      report(<Info key="asset image">
100
+        <Image
101
+          style={styles.image}
102
+          source={{uri: `data:image/png;base64, ${data}`}}/>
103
+      </Info>)
104
+      done()
105
+    })
106
+})
107
+
108
+describe('read asset in app bundle',(report, done) => {
109
+  let target = fs.asset('test-asset2.png')
110
+  fs.readFile(target, 'base64')
111
+  .then((data) => {
112
+    report(<Info key="asset image">
113
+      <Image
114
+        style={styles.image}
115
+        source={{uri: `data:image/png;base64, ${data}`}}/>
116
+    </Info>)
117
+    return fs.readFile(fs.asset('test-asset1.json'), 'utf8')
118
+  })
119
+  .then((resp) => {
120
+    report(
121
+      <Assert key="asset content verify"
122
+        expect="asset#1"
123
+        actual={JSON.parse(resp).secret}/>)
124
+      done()
125
+  })
126
+})
127
+
128
+describe('stat assets in app', (report, done) => {
129
+  fs.stat(fs.asset('test-asset2.png'))
130
+    .then((data) => {
131
+      report(<Info key="list of assets">
132
+        <Text>{JSON.stringify(data)}</Text>
133
+      </Info>)
134
+      done()
135
+    })
136
+})
137
+
138
+describe('copy asset', (report, done) => {
139
+  let dest = `${dirs.DocumentDir}/test-asset-1-${Date.now()}.json`
140
+  fs.cp(fs.asset('test-asset1.json'), dest)
141
+    .then(() => fs.readFile(dest, 'utf8'))
142
+    .then((data) => {
143
+      report(<Assert key="asset copied correctly"
144
+        expect={'asset#1'}
145
+        actual={JSON.parse(data).secret}/>)
146
+      return fs.stat(fs.asset('test-asset1.json'))
147
+    })
148
+    .then((stat) => {
149
+      report(<Assert key="file size check"
150
+        expect={27}
151
+        actual={Math.floor(stat.size)}/>,
152
+      <Info key="dest file info">
153
+        <Text>{JSON.stringify(stat)}</Text>
154
+      </Info>)
155
+      done()
156
+    })
157
+})
158
+
159
+
160
+describe('upload file from assets',(report, done) => {
161
+  let assetName = fs.asset('test-asset1.json')
162
+  RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
163
+    Authorization : `Bearer ${DROPBOX_TOKEN}`,
164
+    'Dropbox-API-Arg': `{\"path\": \"/rn-upload/file-from-asset-${Platform.OS}.json\",\"mode\": \"add\",\"autorename\": false,\"mute\": false}`,
165
+    'Content-Type' : 'application/octet-stream',
166
+  }, RNFetchBlob.wrap(assetName))
167
+  .then((resp) => {
168
+    resp = resp.json()
169
+    report(
170
+      <Assert key="file name check"
171
+        expect={`file-from-asset-${Platform.OS}.json`}
172
+        actual={resp.name}/>)
173
+    done()
174
+  })
175
+})
176 176
 
177 177
 describe('Check custom MIME type correctness',(report, done) => {
178 178
   RNFetchBlob

+ 1
- 1
test/test-0.6.3.js Parādīt failu

@@ -27,7 +27,7 @@ const  dirs = RNFetchBlob.fs.dirs
27 27
 
28 28
 let prefix = ((Platform.OS === 'android') ? 'file://' : '')
29 29
 
30
-describe('upload asset from camera roll', (report, done) => {
30
+describe('massive HTTP request', (report, done) => {
31 31
   try {
32 32
   let promises = []
33 33
   let progress = []

+ 7
- 7
test/test-init.js Parādīt failu

@@ -52,11 +52,11 @@ describe('GET image from server', (report, done) => {
52 52
 })
53 53
 
54 54
 
55
-// require('./test-0.1.x-0.4.x')
56
-// require('./test-0.5.1')
57
-// require('./test-0.5.2')
58
-// require('./test-0.6.0')
59
-// require('./test-0.6.2')
55
+require('./test-0.1.x-0.4.x')
56
+require('./test-0.5.1')
57
+require('./test-0.5.2')
58
+require('./test-0.6.0')
59
+require('./test-0.6.2')
60 60
 require('./test-0.6.3')
61
-// require('./test-fs')
62
-// require('./test-android')
61
+require('./test-fs')
62
+require('./test-android')