import RNTest from './react-native-testkit/' import React from 'react' import RNFetchBlob from 'react-native-fetch-blob' import { StyleSheet, Text, View, ScrollView, Platform, Dimensions, Image, } from 'react-native'; const fs = RNFetchBlob.fs const { Assert, Comparer, Info, prop } = RNTest const describe = RNTest.config({ group : '0.6.0', run : true, expand : false, timeout : 10000, }) const { TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop() const dirs = RNFetchBlob.fs.dirs let prefix = ((Platform.OS === 'android') ? 'file://' : '') describe('writeFile and readFile test', (report, done) => { let path = dirs.DocumentDir + '/0.6.0-'+Date.now()+'/writeFileTest'+Date.now() let data = 'hellofrom'+Date.now() fs.writeFile(path, data) .then(() => fs.readFile(path, 'utf8')) .then((actual) => { report() data = 'base64' return fs.writeFile(path, RNFetchBlob.base64.encode('base64'), 'base64') }) .then(() => fs.readFile(path, 'base64')) .then((actual) => { report() data = 'ascii' return fs.writeFile(path, getASCIIArray('ascii'), 'ascii'); }) .then(() => fs.readFile(path, 'ascii')) .then((actual) => { console.log(getASCIIArray(data), actual) report() done() }) }) describe('append file test', (report, done) => { let path = dirs.DocumentDir + '/append-test'+Date.now() let content = 'test on ' + Date.now() fs.writeFile(path, content, 'utf8') .then(() => fs.appendFile(path, '100', 'utf8', true)) .then(() => fs.readFile(path, 'utf8')) .then((data) => { report( ) return fs.appendFile(path, getASCIIArray('200'), 'ascii') }) .then(() => fs.readFile(path, 'ascii')) .then((data) => { report() return fs.appendFile(path, RNFetchBlob.base64.encode('300'), 'base64') }) .then(() => fs.readFile(path, 'base64')) .then((data) => { report() done() }) }) function getASCIIArray(str) { let r = [] for(let i=0;i