No Description

test-0.8.0.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import RNTest from './react-native-testkit/'
  2. import React from 'react'
  3. import RNFetchBlob from 'react-native-fetch-blob'
  4. import {
  5. StyleSheet,
  6. Text,
  7. View,
  8. ScrollView,
  9. Platform,
  10. Dimensions,
  11. Image,
  12. } from 'react-native';
  13. const fs = RNFetchBlob.fs
  14. const { Assert, Comparer, Info, prop } = RNTest
  15. const describe = RNTest.config({
  16. group : '0.8.0',
  17. run : true,
  18. expand : true,
  19. timeout : 10000,
  20. })
  21. const { TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
  22. const dirs = RNFetchBlob.fs.dirs
  23. let prefix = ((Platform.OS === 'android') ? 'file://' : '')
  24. describe('URI encoding support', (report, done) => {
  25. let testData1 = `test date write file from file ${Date.now()}`
  26. let testData2 = `test date write file from file ${Date.now()*Math.random()}`
  27. let file1 = dirs.DocumentDir + '/testFiletFile1' + Date.now()
  28. let file2 = dirs.DocumentDir + '/testFiletFile2' + Date.now()
  29. let init = [fs.createFile(file1, testData1, 'utf8'),
  30. fs.createFile(file2, testData2, 'utf8')]
  31. Promise.all(init)
  32. .then(() => fs.appendFile(file1, file2, 'uri'))
  33. .then(() => fs.readFile(file1, 'utf8'))
  34. .then((data) => {
  35. report(
  36. <Assert key="append content from URI should be correct"
  37. expect={testData1 + testData2}
  38. actual={data}
  39. />)
  40. return fs.writeFile(file1, file2, 'uri')
  41. })
  42. .then(() => fs.readFile(file1, 'utf8'))
  43. .then((data) => {
  44. report(
  45. <Assert key="write content from URI should be correct"
  46. expect={testData2}
  47. actual={data}
  48. />)
  49. done()
  50. })
  51. })
  52. function getASCIIArray(str) {
  53. let r = []
  54. for(let i=0;i<str.length;i++) {
  55. r.push(str[i].charCodeAt(0))
  56. }
  57. return r
  58. }