-
Notifications
You must be signed in to change notification settings - Fork 65
/
weather.clj
49 lines (44 loc) 路 1.92 KB
/
weather.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(ns yetibot.test.commands.weather
(:require
[midje.sweet :refer [facts fact =>]]
[yetibot.commands.weather :refer :all]
[yetibot.commands.weather.formatters :as fmt]))
(def loc-nyc
{:city_name "New York"
:state_code "NY"
:country_code "US"
:temp 0
:app_temp 25
:weather {:icon nil :code nil :description "titlecase me"}
:wind_spd 10
:wind_cdir "N"})
(def loc-bcr
{:city_name "Bucharest"
:state_code "10"
:country_code "RO"
:temp 50
:app_temp 100
:weather {:icon nil :code nil :description "TITLECASE ME"}
:wind_spd 10
:wind_cdir "SSE"})
(def formatters-us (fmt/get-formatters nil (:country_code loc-nyc)))
(def formatters-us-metric (fmt/get-formatters :m (:country_code loc-nyc)))
(def formatters-ro (fmt/get-formatters nil (:country_code loc-bcr)))
(def formatters-ro-imperl (fmt/get-formatters :i (:country_code loc-bcr)))
(facts "about fomatting fns"
(fact fmt/location-title
(fmt/location-title loc-nyc) => "New York, NY (US)"
(fmt/location-title loc-bcr) => "Bucharest (RO)")
(fact fmt/description
(fmt/description formatters-us loc-nyc) => "32.0掳F - Titlecase Me"
(fmt/description formatters-us-metric loc-nyc) => "0.0掳C - Titlecase Me"
(fmt/description formatters-ro loc-bcr) => "50.0掳C - Titlecase Me"
(fmt/description formatters-ro-imperl loc-bcr) => "122.0掳F - Titlecase Me")
(fact fmt/feels-like
(fmt/feels-like formatters-us loc-nyc) => "Feels like 77.0掳F"
(fmt/feels-like formatters-ro loc-bcr) => "Feels like 100.0掳C")
(fact fmt/wind
(fmt/wind formatters-us loc-nyc) => "Winds 6.2 mph N"
(fmt/wind formatters-us-metric loc-nyc) => "Winds 10.0 km/h N"
(fmt/wind formatters-ro loc-bcr) => "Winds 10.0 km/h SSE"
(fmt/wind formatters-ro-imperl loc-bcr) => "Winds 6.2 mph SSE"))