Skip to content

Commit

Permalink
Add more test specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ExcaliburZero committed Jun 14, 2016
1 parent 8f8f24d commit 47e53f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Network/Stockfighter/Trade.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ instance Show OrderType where
show Limit = "limit"
show Market = "market"
show FillOrKill = "fill-or-kill"
show ImmediateOrCancel = "immeditate-or-cancel"
show ImmediateOrCancel = "immediate-or-cancel"

-- | Sends a request for the given order using the given APIKey, and returns
-- the response.
Expand Down
14 changes: 14 additions & 0 deletions test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Network.Stockfighter.Util

spec :: Spec
spec = do
-- Trade
describe "Order" $ do
it "converts into a JSON String" $ do
let order = Order {
Expand All @@ -21,6 +22,19 @@ spec = do
}
byteStringToString (encode order) `shouldBe` "{\"account\":\"EXB123456\",\"venue\":\"TESTEX\",\"symbol\":\"FOOBAR\",\"price\":25000,\"qty\":100,\"direction\":\"buy\",\"orderType\":\"limit\"}"

describe "Direction" $ do
it "converts to correct String representation for API request" $ do
show Buy `shouldBe` "buy"
show Sell `shouldBe` "sell"

describe "OrderType" $ do
it "converts to correct String representation for API request" $ do
show Limit `shouldBe` "limit"
show Market `shouldBe` "market"
show FillOrKill `shouldBe` "fill-or-kill"
show ImmediateOrCancel `shouldBe` "immediate-or-cancel"

-- Util
describe "headerToString" $ do
it "converts a single part header" $ do
headerToString (HTTPHeader [("key", "value")]) `shouldBe` "key:value;"
Expand Down

0 comments on commit 47e53f7

Please sign in to comment.