'use strict'

import hydrate from '../lib/hydrate.js'
import test from 'tape'

test('hydrate response body', t => {
  // cached value
  const value = {
    body: {
      response: '',
      responseText: '',
      responseType: 'text',
      status: 200,
      statusText: 'OK'
    }
  }

  const _response = hydrate(JSON.stringify(value))

  t.equal(_response.responseType, value.body.responseType, 'responseType should be correct ')
  t.equal(_response.responseText, value.body.responseText, 'responseText should be correct ')
  t.equal(_response.response, value.body.response, 'response should be correct ')
  t.equal(_response.status, value.body.status, 'response status should be correct ')
  t.equal(_response.statusText, value.body.statusText, 'response statusText should be correct ')

  t.end()
})

test('hydrate response headers', t => {
  // cached value
  const value = {
    headers: {
      'content-type': 'type/text',
      'content-length': 1234
    }
  }

  const _response = hydrate(JSON.stringify(value))

  t.deepEqual(_response.getAllResponseHeaders(), value.headers, 'cached response should have the getAllResponseHeaders()')
  t.equal(_response.getResponseHeader('content-type'), 'type/text', 'cached response should have the getResponseHeader()')

  t.end()
})

test('hydrate text response', t => {
  t.skip()
  t.end()
})

test('hydrate JSON response', t => {
  t.skip()
  t.end()
})

test('hydrate ArrayBuffer response', t => {
  // instanceof ArrayBuffer
  t.skip()
  t.end()
})

@@ -161,28 +161,8 @@
 : %7B%0A
-      response: '',%0A
     
@@ -290,38 +290,22 @@
 hydrate(
-JSON.stringify(
 value)
-)
 %0A%0A  t.eq
@@ -490,90 +490,8 @@
  ')%0A
-  t.equal(_response.response, value.body.response, 'response should be correct ')%0A
   t.
@@ -771,24 +771,16 @@
 headers:
- %7B%0A     
  'conten
@@ -789,12 +789,10 @@
 type
-'
 : 
-'
 type
@@ -800,18 +800,10 @@
 text
-',%0A      '
+%5Cn
 cont
@@ -816,21 +816,17 @@
 ngth
-'
 : 1234
-%0A    %7D
+%5Cn'
 %0A  %7D
@@ -859,46 +859,36 @@
 ate(
-JSON.stringify(
 value)
-)%0A
 %0A  
-t.deepEqual(
+const allHeaders = 
 _res
@@ -916,16 +916,107 @@
 eaders()
+%0A  const typeHeader = _response.getResponseHeader('content-type')%0A%0A  t.deepEqual(allHeaders
 , value.
@@ -1097,51 +1097,18 @@
 ual(
-_response.getResponseHeader('content-type')
+typeHeader
 , 't

fix failing tests