Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 5137b16

Browse files
committed
Add test cases for #43
1 parent 4c29a21 commit 5137b16

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

test/test-0.6.2.js

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,43 @@ const dirs = RNFetchBlob.fs.dirs
2626

2727
let prefix = ((Platform.OS === 'android') ? 'file://' : '')
2828

29-
CameraRoll.getPhotos({first : 10}, function(resp){console.log(resp)}, (err)=>{console.log(err)})
30-
// .then((resp) => {
31-
// console.log(resp)
32-
// })
33-
// .catch((err) => {
34-
// console.log(err)
35-
// })
3629

37-
describe('access file in assets', (report, done) => {
30+
describe('access assets from camera roll', (report, done) => {
31+
let photo = null
3832
CameraRoll.getPhotos({first : 10})
3933
.then((resp) => {
34+
photo = resp.edges[0].node.image.uri
4035
report(<Info key="items">
41-
<Text>{JSON.stringify(resp)}</Text>
36+
<Text>{photo}</Text>
4237
</Info>)
38+
return fs.readFile(photo, 'base64')
4339
})
44-
.catch((err) => {
45-
console.log(err)
46-
report(<Info key="err">
47-
<Text>{JSON.stringify(err)}</Text>
40+
.then((data) => {
41+
report(<Info key="asset image">
42+
<Image
43+
style={styles.image}
44+
source={{uri: `data:image/png;base64, ${data}`}}/>
4845
</Info>)
46+
done()
4947
})
5048
})
49+
50+
describe('read asset in app bundle',(report, done) => {
51+
let target = 'bundle-assets://test-asset2.png'
52+
fs.readFile(target, 'base64')
53+
.then((data) => {
54+
report(<Info key="asset image">
55+
<Image
56+
style={styles.image}
57+
source={{uri: `data:image/png;base64, ${data}`}}/>
58+
</Info>)
59+
return fs.readFile('bundle-assets://test-asset1.json', 'utf8')
60+
})
61+
.then((resp) => {
62+
report(
63+
<Assert key="asset content verify"
64+
expect="asset#1"
65+
actual={JSON.parse(resp).secret}/>)
66+
done()
67+
})
68+
})

0 commit comments

Comments
 (0)