tutor/test/Spec.hs

20 lines
1.8 KiB
Haskell

{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Lib (app)
import Test.Hspec
import Test.Hspec.Wai
import Test.Hspec.Wai.JSON
main :: IO ()
main = hspec spec
spec :: Spec
spec = with (return app) $ do
describe "GET /search" $ do
it "responds with 200" $ do
get "/search" `shouldRespondWith` 200
it "responds with [Card]" $ do
let cards = "[{\"scryfall_id\":\"f6cd7465-9dd0-473c-ac5e-dd9e2f22f5f6\",\"name\":\"Esika, God of the Tree // The Prismatic Bridge\",\"set_code\":\"KHM\",\"collector_number\":\"168\",\"rarity\":\"mythic\",\"color_identity\":\"WUBGR\",\"oracle_text\":null,\"prices\":{\"usd\":\"9.07\",\"usd_foil\":\"10.77\",\"eur\":\"7.79\",\"eur_foil\":\"12.27\",\"tix\":\"1.08\"}},{\"scryfall_id\":\"d761ff73-0717-4ee4-996b-f5547bcf9b2f\",\"name\":\"Go-Shintai of Life's Origin\",\"set_code\":\"NEC\",\"collector_number\":\"66\",\"rarity\":\"mythic\",\"color_identity\":\"WUBGR\",\"oracle_text\":\"{W}{U}{B}{R}{G}, {T}: Return target enchantment card from your graveyard to the battlefield.\\nWhenever Go-Shintai of Life's Origin or another nontoken Shrine enters the battlefield under your control, create a 1/1 colorless Shrine enchantment creature token.\",\"prices\":{\"usd\":\"23.28\",\"usd_foil\":null,\"eur\":\"23.05\",\"eur_foil\":null,\"tix\":null}},{\"scryfall_id\":\"e2539ff7-2b7d-47e3-bd77-3138a6c42d2b\",\"name\":\"Godsire\",\"set_code\":\"ALA\",\"collector_number\":\"170\",\"rarity\":\"mythic\",\"color_identity\":\"WGR\",\"oracle_text\":\"Vigilance\\n{T}: Create an 8/8 Beast creature token that's red, green, and white.\",\"prices\":{\"usd\":\"7.22\",\"usd_foil\":\"16.56\",\"eur\":\"4.00\",\"eur_foil\":\"13.95\",\"tix\":\"0.02\"}}]"
get "/search" `shouldRespondWith` cards