module Channel.BitcoinSpec (main, spec) where

import           Helper
import           System.Random
import qualified Data.ByteString.Lazy as L

import           Channel.Command
import           Channel.Event

import           Channel.Bitcoin

main :: IO ()
main = hspec spec

spec :: Spec
spec = do
  describe "bitcoin" $ do
    it "makes Alonzo convert from and to BTC" $ do
      run "alonzo" [] mockedHttp (mkStdGen 0) (bitcoin $ Message "you" "alonzo: 1 BTC") `shouldReturn` [Say "1 BTC is 100.20 EUR (at rate 100.20)"]
    where
     mockedHttp "http://data.mtgox.com/api/1/BTCEUR/ticker" = L.readFile "test/fixtures/bitcoin.json"
     mockedHttp url = error ("unexpected request to " ++ url)
