import RNTest from './react-native-testkit/'
import React from 'react'
import _ from 'lodash'
import RNFetchBlob from 'react-native-fetch-blob'

import {
  StyleSheet,
  Text,
  View,
  ScrollView,
  Dimensions,
  Platform,
  Dimension,
  Image,
} from 'react-native';

const { Assert, Comparer, Info, prop } = RNTest

// test environment variables

prop('FILENAME', `${Platform.OS}-0.10.0-${Date.now()}.png`)
prop('TEST_SERVER_URL', 'http://localhost:8123')
prop('TEST_SERVER_URL_SSL', 'https://localhost:8124')
// prop('TEST_SERVER_URL', 'http://192.168.1.6:8123')
// prop('TEST_SERVER_URL_SSL', 'https://192.168.1.6:8124')
prop('DROPBOX_TOKEN', 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4')
prop('styles', {
  image : {
    width: Dimensions.get('window').width*0.9,
    height : Dimensions.get('window').width*0.9,
    margin : 16,
    flex : 1
  }
})

const { TEST_SERVER_URL, FILENAME, DROPBOX_TOKEN, styles, image } = prop()

const describe = RNTest.config({
  run : true,
  expand : true,
  timeout : 5000,
})

// init

describe('#225 upload progress should fire correctly', (report, done) => {

  let data = '';
  let fired = false;
  for(let i =0; i< 100000; i++) {
    data += 'chunkchunk'
  }
  let upload = RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload`, {
    'Content-Type' : 'text/plain;BASE64'
  }, data)
  upload.uploadProgress((total, now) => {
    console.log(total, now)
    fired = true;
  })
  upload.then(() => {
    report(<Assert key="progress event fired" expect={true} actual={fired}/>);
    done()
  })
})

describe('GET image from server', (report, done) => {

  RNFetchBlob
    .fetch('GET', `${TEST_SERVER_URL}/public/github.png`, {
      Authorization : 'Bearer abde123eqweje'
    })
    .then((resp) => {
      RNTest.prop('image', resp.base64())
      report(
        <Info key="Response image">
          <Image
            style={styles.image}
            source={{uri : `data:image/png;base64, ${prop('image')}`}}/>
        </Info>)
        done()
    })
})


// require('./test-0.1.x-0.4.x')
// require('./test-0.5.1')
// require('./test-0.5.2')
// require('./test-0.6.0')
// require('./test-0.6.2')
// require('./test-0.7.0')
// require('./test-0.8.0')
// require('./test-0.9.0')
// require('./test-0.9.2')
// require('./test-0.9.4')
// require('./test-0.9.5')
// require('./test-0.9.6')
// require('./test-0.10.0')
// require('./test-0.10.1')
// require('./test-0.10.2')
// require('./test-0.10.3')
// require('./test-0.10.5')
// require('./test-0.10.6')
require('./test-0.10.7')
// require('./test-background.js')
// require('./test-stream')
// require('./test-fetch')
// require('./test-fs')
// require('./test-xmlhttp')
// require('./test-blob')
// require('./test-firebase')
// require('./test-android')
// require('./test-stress')
// require('./benchmark')

@@ -403,16 +403,20 @@
 %7D.png%60)%0A
+%0A// 
 prop('TE
@@ -456,16 +456,19 @@
 :8123')%0A
+// 
 prop('TE
@@ -513,19 +513,197 @@
 :8124')%0A
+%0A
 // 
+When running in the Android emulator 10.0.2.2 is the IP to reach 127.0.0.1 of the host running the emulator%0A// https://developer.android.com/studio/run/emulator-networking.html%0A
 prop('TE
@@ -731,26 +731,23 @@
 ://1
-92.168.1.6
+0.0.2.2
 :8123')%0A
 // p
@@ -734,35 +734,32 @@
 10.0.2.2:8123')%0A
-// 
 prop('TEST_SERVE
@@ -784,26 +784,23 @@
 ://1
-92.168.1.6
+0.0.2.2
 :8124')%0A
 prop
@@ -791,24 +791,25 @@
 .2.2:8124')%0A
+%0A
 prop('DROPBO
@@ -823,72 +823,23 @@
 ', '
-fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4
+YOUR TOKEN HERE
 ')%0Ap
@@ -2734,19 +2734,16 @@
 tream')%0A
-// 
 require(
@@ -2758,19 +2758,16 @@
 fetch')%0A
-// 
 require(

add Android emulator test server IP and comment