-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
module TestTypes where | ||
|
||
{- Test Types module -} | ||
|
||
import Control.Lens | ||
|
||
import Data.Maybe | ||
import Data.Time | ||
import Data.Time.LocalTime.TimeZone.Series | ||
|
||
import Types | ||
import Types.Location | ||
import Types.Location.Japan | ||
|
||
import Test.Hspec | ||
|
||
|
||
japanTime :: Day -> Int -> Int -> UTCTime | ||
japanTime date hour minute = localTimeToUTC' japanTZ $ LocalTime date $ TimeOfDay hour minute 0 | ||
|
||
|
||
spec :: Spec | ||
spec = do | ||
describe "buildForecast" $ do | ||
context "builds the forecast for the right time zone" $ do | ||
let Just date = fromGregorianValid 2016 09 01 | ||
let atHour h = japanTime date h 0 | ||
let tokyo = Location "Japan" "Tokyo" "Tokyo" | ||
it "is Nothing when there is no alert" $ | ||
buildForecast tokyo (atHour 19) [] `shouldBe` Nothing | ||
it "has correct date and times when there is an alert" $ do | ||
let levels = [ (atHour 6, UVLevel 1) | ||
, (atHour 7, UVLevel 2) | ||
, (atHour 8, UVLevel 3) | ||
, (atHour 9, UVLevel 4) | ||
, (atHour 10, UVLevel 5) | ||
, (atHour 11, UVLevel 4) | ||
, (atHour 12, UVLevel 3) | ||
, (atHour 13, UVLevel 2) | ||
, (atHour 14, UVLevel 1) | ||
] | ||
let Just forecast = buildForecast tokyo (atHour 19) levels | ||
(forecast ^. fcDate) `shouldBe` (fromJust $ fromGregorianValid 2016 09 01) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters