From 65464b76e0ebc15427fba282b8c27487f307bde3 Mon Sep 17 00:00:00 2001 From: Neyts Zupan Date: Tue, 6 Feb 2024 16:54:24 +0000 Subject: [PATCH] fix tests --- src/Config.elm | 9 +++++++-- src/Main.elm | 8 ++++---- tests/Tests.elm | 30 +++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/Config.elm b/src/Config.elm index ccf6556..fcda2cc 100644 --- a/src/Config.elm +++ b/src/Config.elm @@ -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 } @@ -30,6 +30,8 @@ type alias Config = Decode.decodeString configDecoder """ { + "careers_updated" : "1999-01-01", + "countries_updated" : "2000-01-01", "countries" : [ { "name": "Spain", @@ -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 ] diff --git a/src/Main.elm b/src/Main.elm index 1ce5de5..54ab1ef 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -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 -> @@ -718,10 +718,10 @@ humanizeTenure years = --> "30%" humanizeCommitmentBonus 0.12345 - --> "12%" + --> "12.34%" humanizeCommitmentBonus 0.126 - --> "13%" + --> "12.6%" humanizeCommitmentBonus 3.0 --> "300%" diff --git a/tests/Tests.elm b/tests/Tests.elm index 57135dd..ff38974 100644 --- a/tests/Tests.elm +++ b/tests/Tests.elm @@ -56,6 +56,8 @@ testInitHappyPath = json = """ { + "careers_updated": "1999-01-01", + "countries_updated": "2000-01-01", "countries": [ { "name": "Netherlands", @@ -119,6 +121,8 @@ testInitHappyPath = , roleDropdown = Dropdown.initialState , countryDropdown = Dropdown.initialState , tenureDropdown = Dropdown.initialState + , careers_updated = "1999-01-01" + , countries_updated = "2000-01-01" } ) @@ -129,6 +133,8 @@ testInitQueryString = json = """ { + "careers_updated": "1999-01-01", + "countries_updated": "2000-01-01", "countries": [ { "name": "Netherlands", @@ -192,6 +198,8 @@ testInitQueryString = , roleDropdown = Dropdown.initialState , countryDropdown = Dropdown.initialState , tenureDropdown = Dropdown.initialState + , careers_updated = "1999-01-01" + , countries_updated = "2000-01-01" } ) @@ -202,6 +210,8 @@ testInitInvalidQueryString = json = """ { + "careers_updated": "1999-01-01", + "countries_updated": "2000-01-01", "countries": [ { "name": "Netherlands", @@ -268,6 +278,8 @@ testInitInvalidQueryString = , roleDropdown = Dropdown.initialState , countryDropdown = Dropdown.initialState , tenureDropdown = Dropdown.initialState + , careers_updated = "1999-01-01" + , countries_updated = "2000-01-01" } ) @@ -310,6 +322,8 @@ testInitMissingCountries = , roleDropdown = Dropdown.initialState , countryDropdown = Dropdown.initialState , tenureDropdown = Dropdown.initialState + , careers_updated = "1970-01-01" + , countries_updated = "1970-01-01" } ) @@ -357,6 +371,8 @@ testInitMissingCareers = , roleDropdown = Dropdown.initialState , countryDropdown = Dropdown.initialState , tenureDropdown = Dropdown.initialState + , careers_updated = "1970-01-01" + , countries_updated = "1970-01-01" } ) @@ -409,6 +425,8 @@ testInitMissingRoles = , roleDropdown = Dropdown.initialState , countryDropdown = Dropdown.initialState , tenureDropdown = Dropdown.initialState + , careers_updated = "1970-01-01" + , countries_updated = "1970-01-01" } ) @@ -450,6 +468,8 @@ testInitInvalidConfig = , roleDropdown = Dropdown.initialState , countryDropdown = Dropdown.initialState , tenureDropdown = Dropdown.initialState + , careers_updated = "1970-01-01" + , countries_updated = "1970-01-01" } ) @@ -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%" ] @@ -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 @@ -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