Aucune description

test-init.js 2.7KB

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