Brak opisu

test-init.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. Dimensions,
  10. Platform,
  11. Dimension,
  12. Image,
  13. } from 'react-native';
  14. const { Assert, Comparer, Info, prop } = RNTest
  15. // test environment variables
  16. prop('FILENAME', `${Platform.OS}-0.10.0-${Date.now()}.png`)
  17. prop('TEST_SERVER_URL', 'http://localhost:8123')
  18. prop('TEST_SERVER_URL_SSL', 'https://localhost:8124')
  19. // prop('TEST_SERVER_URL', 'http://192.168.17.185:8123')
  20. // prop('TEST_SERVER_URL_SSL', 'https://192.168.17.185:8124')
  21. prop('DROPBOX_TOKEN', 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4')
  22. prop('styles', {
  23. image : {
  24. width: Dimensions.get('window').width*0.9,
  25. height : Dimensions.get('window').width*0.9,
  26. margin : 16,
  27. flex : 1
  28. }
  29. })
  30. const { TEST_SERVER_URL, FILENAME, DROPBOX_TOKEN, styles, image } = prop()
  31. const describe = RNTest.config({
  32. run : true,
  33. expand : true,
  34. timeout : 5000,
  35. })
  36. // init
  37. describe('#225 upload progress should fire correctly', (report, done) => {
  38. let data = '';
  39. let fired = false;
  40. for(let i =0; i< 100000; i++) {
  41. data += 'chunkchunk'
  42. }
  43. let upload = RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload`, {
  44. 'Content-Type' : 'text/plain;BASE64'
  45. }, data)
  46. upload.uploadProgress((total, now) => {
  47. console.log(total, now)
  48. fired = true;
  49. })
  50. upload.then(() => {
  51. report(<Assert key="progress event fired" expect={true} actual={fired}/>);
  52. done()
  53. })
  54. })
  55. describe('GET image from server', (report, done) => {
  56. RNFetchBlob
  57. .fetch('GET', `${TEST_SERVER_URL}/public/github.png`, {
  58. Authorization : 'Bearer abde123eqweje'
  59. })
  60. .then((resp) => {
  61. RNTest.prop('image', resp.base64())
  62. report(
  63. <Info key="Response image">
  64. <Image
  65. style={styles.image}
  66. source={{uri : `data:image/png;base64, ${prop('image')}`}}/>
  67. </Info>)
  68. done()
  69. })
  70. })
  71. // require('./test-0.1.x-0.4.x')
  72. // require('./test-0.5.1')
  73. // require('./test-0.5.2')
  74. // require('./test-0.6.0')
  75. // require('./test-0.6.2')
  76. // require('./test-0.7.0')
  77. // require('./test-0.8.0')
  78. // require('./test-0.9.0')
  79. // require('./test-0.9.2')
  80. // require('./test-0.9.4')
  81. // require('./test-0.9.5')
  82. // require('./test-0.9.6')
  83. // require('./test-0.10.0')
  84. // require('./test-0.10.1')
  85. require('./test-0.10.2')
  86. // require('./test-background.js')
  87. // require('./test-stream')
  88. // require('./test-fetch')
  89. // require('./test-fs')
  90. // require('./test-xmlhttp')
  91. // require('./test-blob')
  92. // require('./test-firebase')
  93. // require('./test-android')
  94. // require('./test-stress')
  95. // require('./benchmark')