Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zupo committed Feb 7, 2024
1 parent 644ad2a commit 65464b7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/Config.elm
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import Json.Decode as Decode
type alias Config =
{ countries : List Country
, careers : List Career
, countries_updated : String
, careers_updated : String
, countries_updated : String
}


Expand All @@ -30,6 +30,8 @@ type alias Config =
Decode.decodeString configDecoder """
{
"careers_updated" : "1999-01-01",
"countries_updated" : "2000-01-01",
"countries" : [
{
"name": "Spain",
Expand All @@ -50,7 +52,10 @@ type alias Config =
}
"""
--> Ok
--> { countries = [ Country "Spain" 1.87 ]
--> {
--> careers_updated = "1999-01-01"
--> , countries_updated = "2000-01-01"
--> , countries = [ Country "Spain" 1.87 ]
--> , careers =
--> [ Career "Design"
--> [ Role "Junior Designer" 2345 ]
Expand Down
8 changes: 4 additions & 4 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ init flags =
, roleDropdown = Dropdown.initialState
, countryDropdown = Dropdown.initialState
, tenureDropdown = Dropdown.initialState
, careers_updated = "1999-01-01"
, countries_updated = "1999-01-01"
, careers_updated = "1970-01-01"
, countries_updated = "1970-01-01"
}

Ok config ->
Expand Down Expand Up @@ -718,10 +718,10 @@ humanizeTenure years =
--> "30%"
humanizeCommitmentBonus 0.12345
--> "12%"
--> "12.34%"
humanizeCommitmentBonus 0.126
--> "13%"
--> "12.6%"
humanizeCommitmentBonus 3.0
--> "300%"
Expand Down
30 changes: 27 additions & 3 deletions tests/Tests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ testInitHappyPath =
json =
"""
{
"careers_updated": "1999-01-01",
"countries_updated": "2000-01-01",
"countries": [
{
"name": "Netherlands",
Expand Down Expand Up @@ -119,6 +121,8 @@ testInitHappyPath =
, roleDropdown = Dropdown.initialState
, countryDropdown = Dropdown.initialState
, tenureDropdown = Dropdown.initialState
, careers_updated = "1999-01-01"
, countries_updated = "2000-01-01"
}
)

Expand All @@ -129,6 +133,8 @@ testInitQueryString =
json =
"""
{
"careers_updated": "1999-01-01",
"countries_updated": "2000-01-01",
"countries": [
{
"name": "Netherlands",
Expand Down Expand Up @@ -192,6 +198,8 @@ testInitQueryString =
, roleDropdown = Dropdown.initialState
, countryDropdown = Dropdown.initialState
, tenureDropdown = Dropdown.initialState
, careers_updated = "1999-01-01"
, countries_updated = "2000-01-01"
}
)

Expand All @@ -202,6 +210,8 @@ testInitInvalidQueryString =
json =
"""
{
"careers_updated": "1999-01-01",
"countries_updated": "2000-01-01",
"countries": [
{
"name": "Netherlands",
Expand Down Expand Up @@ -268,6 +278,8 @@ testInitInvalidQueryString =
, roleDropdown = Dropdown.initialState
, countryDropdown = Dropdown.initialState
, tenureDropdown = Dropdown.initialState
, careers_updated = "1999-01-01"
, countries_updated = "2000-01-01"
}
)

Expand Down Expand Up @@ -310,6 +322,8 @@ testInitMissingCountries =
, roleDropdown = Dropdown.initialState
, countryDropdown = Dropdown.initialState
, tenureDropdown = Dropdown.initialState
, careers_updated = "1970-01-01"
, countries_updated = "1970-01-01"
}
)

Expand Down Expand Up @@ -357,6 +371,8 @@ testInitMissingCareers =
, roleDropdown = Dropdown.initialState
, countryDropdown = Dropdown.initialState
, tenureDropdown = Dropdown.initialState
, careers_updated = "1970-01-01"
, countries_updated = "1970-01-01"
}
)

Expand Down Expand Up @@ -409,6 +425,8 @@ testInitMissingRoles =
, roleDropdown = Dropdown.initialState
, countryDropdown = Dropdown.initialState
, tenureDropdown = Dropdown.initialState
, careers_updated = "1970-01-01"
, countries_updated = "1970-01-01"
}
)

Expand Down Expand Up @@ -450,6 +468,8 @@ testInitInvalidConfig =
, roleDropdown = Dropdown.initialState
, countryDropdown = Dropdown.initialState
, tenureDropdown = Dropdown.initialState
, careers_updated = "1970-01-01"
, countries_updated = "1970-01-01"
}
)

Expand Down Expand Up @@ -550,12 +570,12 @@ testHumanizeCommitmentBonus =
|> Expect.equal "0%"
, test "0.011" <|
\_ ->
humanizeCommitmentBonus 0.011
|> Expect.equal "1%"
humanizeCommitmentBonus 0.0101
|> Expect.equal "1.01%"
, test "0.125" <|
\_ ->
humanizeCommitmentBonus 0.125
|> Expect.equal "13%"
|> Expect.equal "12.5%"
]


Expand Down Expand Up @@ -608,6 +628,8 @@ hideWarnings =
, roleDropdown = Dropdown.initialState
, countryDropdown = Dropdown.initialState
, tenureDropdown = Dropdown.initialState
, careers_updated = "1970-01-01"
, countries_updated = "1970-01-01"
}
|> Tuple.first
|> .warnings
Expand All @@ -626,6 +648,8 @@ hideWarnings =
, roleDropdown = Dropdown.initialState
, countryDropdown = Dropdown.initialState
, tenureDropdown = Dropdown.initialState
, careers_updated = "1970-01-01"
, countries_updated = "1970-01-01"
}
|> Tuple.first
|> .warnings
Expand Down

0 comments on commit 65464b7

Please sign in to comment.