Skip to content

Commit

Permalink
chore: Put back Kåren-test with fresh data
Browse files Browse the repository at this point in the history
Thank you @The1Penguin for the feedback!

Run this in the repl to get fresh test data:

```Haskell
dateNow <- fmap (view _zonedTimeToLocalTime) getZonedTime
tomorrow = (dateNow & (_localDay . gregorian . _ymdDay) %~ (+ 1)) ^. _localDay
runStack $ fetch "21f31565-5c2b-4b47-d2a1-08d558129279" tomorrow
```

Then run the test and adjust the expected data to match the actual data.
This is the backwards way to write tests, but I think it's alright when
it's this easy to see if expectation and actual data matches.
  • Loading branch information
Rembane committed Sep 24, 2023
1 parent ae0cb4e commit 41d04a1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ testFun expected = either

main :: IO ()
main = hspec $ do
describe "hasDate"
$ it "parses a legit date" (hasDate (BL8.pack "2/1") @?= Just (1, 2))
describe "The Karen Express" $ it
"parses a blob of JSON without error"
( testFun
[ Menu
(T.pack "Street food")
(T.pack "Chicken africana, banan, mango raja, ris")
, Menu
(T.pack "Greens")
(T.pack "Indisklinsgryta, zucchini, aubergin, ingef\228ra, koriander, ris")
, Menu
(T.pack "Nordic")
(T.pack "F\228rskost bakad sej, vitvinss\229s, broccoli, potatis")
]
$ parse
"Swedish"
(BL8.pack
"{\"data\":{\"dishOccurrencesByTimeRange\":[{\"displayNames\":[{\"name\":\"Chicken africana, banan, mango raja, ris\",\"categoryName\":\"Swedish\"},{\"name\":\"Chicken africana, banana, mango raja, rice\",\"categoryName\":\"English\"}],\"startDate\":\"09/25/2023 00:00:00\",\"dishType\":{\"name\":\"Street food\"},\"dish\":{\"name\":\"Kyckling, het paprikas\195\165s & ris\"}},{\"displayNames\":[{\"name\":\"Indian linseed stew, zucchini, aubergine, ginger, coriander\",\"categoryName\":\"English\"},{\"name\":\"Indisklinsgryta, zucchini, aubergin, ingef\195\164ra, koriander, ris\",\"categoryName\":\"Swedish\"}],\"startDate\":\"09/25/2023 00:00:00\",\"dishType\":{\"name\":\"Greens\"},\"dish\":{\"name\":\"Vegan, pasta, linsbolognese\"}},{\"displayNames\":[{\"name\":\"F\195\164rskost bakad sej, vitvinss\195\165s, broccoli, potatis\",\"categoryName\":\"Swedish\"},{\"name\":\"Cream cheese baked saithe, whitewine sauce, broccoli, potatoes\",\"categoryName\":\"English\"}],\"startDate\":\"09/25/2023 00:00:00\",\"dishType\":{\"name\":\"Nordic\"},\"dish\":{\"name\":\"Bakad fisk, vitvinss\195\165s, potatispur\195\169\"}}]}}\n"
)
)

describe "The Wijkander's"
$ it "Parses two blobs of HTML correctly on fridays"
$ do
Expand Down

0 comments on commit 41d04a1

Please sign in to comment.