@@ -76,74 +76,74 @@ describe('Upload multipart data with file from CameraRoll', (report, done) => {
7676 } )
7777} )
7878
79- //
80- // describe('access assets from camera roll', (report, done) => {
81- // let photo = null
82- // CameraRoll.getPhotos({first : 10})
83- // .then((resp) => {
84- // photo = resp.edges[0].node.image.uri
85- // report(<Info key="items">
86- // <Text>{photo}</Text>
87- // </Info>)
88- // return fs.readFile(photo, 'base64')
89- // })
90- // .then((data) => {
91- // report(<Info key="asset image">
92- // <Image
93- // style={styles.image}
94- // source={{uri: `data:image/png;base64, ${data}`}}/>
95- // </Info>)
96- // done()
97- // })
98- // })
99- //
100- // describe('read asset in app bundle',(report, done) => {
101- // let target = fs.asset('test-asset2.png')
102- // fs.readFile(target, 'base64')
103- // .then((data) => {
104- // report(<Info key="asset image">
105- // <Image
106- // style={styles.image}
107- // source={{uri: `data:image/png;base64, ${data}`}}/>
108- // </Info>)
109- // return fs.readFile(fs.asset('test-asset1.json'), 'utf8')
110- // })
111- // .then((resp) => {
112- // report(
113- // <Assert key="asset content verify"
114- // expect="asset#1"
115- // actual={JSON.parse(resp).secret}/>)
116- // done()
117- // })
118- // })
119- //
120- // describe('stat assets in app', (report, done) => {
121- // fs.stat(fs.asset('test-asset2.png'))
122- // .then((data) => {
123- // report(<Info key="list of assets">
124- // <Text>{JSON.stringify(data)}</Text>
125- // </Info>)
126- // done()
127- // })
128- // })
129- //
130- // describe('copy asset', (report, done) => {
131- // let dest = `${dirs.DocumentDir}/test-asset-1-${Date.now()}.json`
132- // fs.cp(fs.asset('test-asset1.json'), dest)
133- // .then(() => fs.readFile(dest, 'utf8'))
134- // .then((data) => {
135- // report(<Assert key="asset copied correctly"
136- // expect={'asset#1'}
137- // actual={JSON.parse(data).secret}/>)
138- // return fs.stat(fs.asset('test-asset1.json'))
139- // })
140- // .then((stat) => {
141- // report(<Assert key="file size check"
142- // expect={27}
143- // actual={Math.floor(stat.size)}/>,
144- // <Info key="dest file info">
145- // <Text>{JSON.stringify(stat)}</Text>
146- // </Info>)
147- // done()
148- // })
149- // })
79+
80+ describe ( 'access assets from camera roll' , ( report , done ) => {
81+ let photo = null
82+ CameraRoll . getPhotos ( { first : 10 } )
83+ . then ( ( resp ) => {
84+ photo = resp . edges [ 0 ] . node . image . uri
85+ report ( < Info key = "items" >
86+ < Text > { photo } </ Text >
87+ </ Info > )
88+ return fs . readFile ( photo , 'base64' )
89+ } )
90+ . then ( ( data ) => {
91+ report ( < Info key = "asset image" >
92+ < Image
93+ style = { styles . image }
94+ source = { { uri : `data:image/png;base64, ${ data } ` } } />
95+ </ Info > )
96+ done ( )
97+ } )
98+ } )
99+
100+ describe ( 'read asset in app bundle' , ( report , done ) => {
101+ let target = fs . asset ( 'test-asset2.png' )
102+ fs . readFile ( target , 'base64' )
103+ . then ( ( data ) => {
104+ report ( < Info key = "asset image" >
105+ < Image
106+ style = { styles . image }
107+ source = { { uri : `data:image/png;base64, ${ data } ` } } />
108+ </ Info > )
109+ return fs . readFile ( fs . asset ( 'test-asset1.json' ) , 'utf8' )
110+ } )
111+ . then ( ( resp ) => {
112+ report (
113+ < Assert key = "asset content verify"
114+ expect = "asset#1"
115+ actual = { JSON . parse ( resp ) . secret } /> )
116+ done ( )
117+ } )
118+ } )
119+
120+ describe ( 'stat assets in app' , ( report , done ) => {
121+ fs . stat ( fs . asset ( 'test-asset2.png' ) )
122+ . then ( ( data ) => {
123+ report ( < Info key = "list of assets" >
124+ < Text > { JSON . stringify ( data ) } </ Text >
125+ </ Info > )
126+ done ( )
127+ } )
128+ } )
129+
130+ describe ( 'copy asset' , ( report , done ) => {
131+ let dest = `${ dirs . DocumentDir } /test-asset-1-${ Date . now ( ) } .json`
132+ fs . cp ( fs . asset ( 'test-asset1.json' ) , dest )
133+ . then ( ( ) => fs . readFile ( dest , 'utf8' ) )
134+ . then ( ( data ) => {
135+ report ( < Assert key = "asset copied correctly"
136+ expect = { 'asset#1' }
137+ actual = { JSON . parse ( data ) . secret } /> )
138+ return fs . stat ( fs . asset ( 'test-asset1.json' ) )
139+ } )
140+ . then ( ( stat ) => {
141+ report ( < Assert key = "file size check"
142+ expect = { 27 }
143+ actual = { Math . floor ( stat . size ) } /> ,
144+ < Info key = "dest file info" >
145+ < Text > { JSON . stringify ( stat ) } </ Text >
146+ </ Info > )
147+ done ( )
148+ } )
149+ } )
0 commit comments