import assert from 'assert'
import toUpperCase from '../package/string/toUpperCase'
import Future from '../package/future'

describe('A Future', () => {
  it('should map over the data',
    () =>
      Future((reject, resolve) => resolve('hello exalted one'))
        .map(toUpperCase)
        .fork(
        error => assert(false, error),
        data => assert(data === 'HELLO EXALTED ONE')))

  it('should not execute untill fork is called',
    () => {
      /**
       * I'm using assignment here because I
       * have to track as a side effect, the
       * map function call.
       */
      let executed = false
      const f = Future((reject, resolve) =>
        (executed = true, resolve(true)))

      assert(!executed)

      f.fork(
        () => assert(false, 'should not get here'),
        (data) => {
          assert(data === true)
          assert(executed === true)
        })
    })

  it('should not execute map untill fork is called',
    () => {
      /**
       * I'm using assignment here because I
       * have to track as a side effect, the
       * map function call.
       */
      let executed = false
      const f = Future((reject, resolve) => {
        executed = true
        resolve(true)
      })

      f.map((a) => {
        executed = false
        return a
      })

      assert(!executed, 'should not execute')

      f.fork(
        () => assert(false, 'should not get here'),
        (data) => {
          assert(data === true)
          assert(executed === true)
        })
    })
})

@@ -654,24 +654,26 @@
  resolve) =%3E
+ %7B
 %0A        (ex
@@ -669,17 +669,16 @@
         
-(
 executed
@@ -684,17 +684,24 @@
 d = true
-,
+%0A       
  resolve
@@ -706,17 +706,24 @@
 ve(true)
-)
+%0A      %7D
 )%0A%0A     

fix lint