var test = require('tape')
var nock = require('nock')

var Account = require('../../index')

var baseURL = 'http://localhost:3000'
var signUpResponse = require('../fixtures/signup.json')
var signInResponse = require('../fixtures/signin.json')
var options = {
  username: signUpResponse.data.attributes.username,
  password: 'secret'
}

test('returns correct signedIn state', function (t) {
  t.plan(2)

  var account = new Account({
    url: baseURL
  })

  nock(baseURL)
    .put('/session/account')
    .reply(200, signUpResponse)
    .put('/session')
    .reply(201, signInResponse)
    .delete('/session')
    .reply(204)

  account.signUp(options)

  .then(function () {
    return account.signIn(options)
  })

  .then(function () {
    t.is(account.isSignedIn(), true, 'returns true after signIn()')

    return account.signOut()
  })

  .then(function () {
    t.is(account.isSignedIn(), false, 'returns false after signOut()')
  })

  .catch(t.error)
})

@@ -24,706 +24,205 @@
 e')%0A
-var nock = require('nock')%0A%0Avar Account = require('../../index')%0A%0Avar baseURL = 'http://localhost:3000'%0Avar signUpResponse = require('../fixtures/signup.json')%0Avar signInResponse = require('../fixtures/signin.json')%0Avar options = %7B%0A  username: signUpResponse.data.attributes.username,%0A  password: 'secret'%0A%7D%0A%0Atest('returns correct signedIn state', function (t) %7B%0A  t.plan(2)%0A%0A  var account = new Account(%7B%0A    url: baseURL%0A  %7D)%0A%0A  nock(baseURL)%0A    .put('/session/account')%0A    .reply(200, signUpResponse)%0A    .put('/session
+%0Avar isSignedIn = require('../../lib/is-signed-in')%0A%0Atest('isSignedIn without session', function (t) %7B%0A  t.is(isSignedIn(%7B%7D), false, 'returns false
 ')%0A
+%0A
   
-  .reply(201, signInResponse)%0A    .delete('/session')%0A    .reply(204)%0A%0A  account.signUp(options)%0A%0A  .then(function () %7B%0A    return account.signIn(options)%0A  %7D)%0A%0A  .then(
+t.end()%0A%7D)%0A%0Atest('isSignedIn with session', 
 func
@@ -227,37 +227,28 @@
 nction (
+t
 ) %7B%0A
-  
   t.is(
-account.
 isSigned
@@ -254,199 +254,63 @@
 dIn(
-), true, 'returns true after signIn()')%0A%0A    return account.signOut()%0A  %7D)%0A%0A  .then(function ()
+%7B%0A    session:
  %7B
+%7D
 %0A  
-  t.is(account.isSignedIn(), false, 'returns false after signOut()')%0A  %7D)%0A%0A  .catch(t.error
+%7D), true, 'returns true')%0A%0A  t.end(
 )%0A%7D)

unit-ify isSignedIn test