Skip to content
This repository has been archived by the owner on Feb 28, 2018. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeriochaves committed Jan 26, 2017
1 parent e20798f commit 286a703
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
4 changes: 2 additions & 2 deletions jarbas/frontend/elm/Reimbursement/Fields.elm
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ sets =

{-| Filter to get numbers only fields:
>>> isNumeric "year"
>>> isNumeric Year
True
>>> isNumeric "format"
>>> isNumeric Company
False
-}
Expand Down
16 changes: 15 additions & 1 deletion jarbas/frontend/elm/Reimbursement/Search/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,22 @@ updateFromQuery model query =
model


{-| Convert a list of non-empty, searchable fields into a pair of key/value:
>>> import Reimbursement.Fields exposing (Field(..), Label(..))
>>> toQuery [ Field Year "2016" ]
[ ( "year", "2016" ) ]
>>> toQuery [ Field LegOfTheTrip "any" ]
[]
>>> toQuery [ Field Year "" ]
[]
-}
toQuery : Model -> List ( String, String )
toQuery model =
model
|> List.filter (Fields.getValue >> String.trim >> String.isEmpty >> not)
|> List.map (\(Field label value) -> ( Fields.labelToUrl label, value |> String.trim ))
|> List.filter (Tuple.first >> String.isEmpty >> not)
|> List.filter (Tuple.second >> String.isEmpty >> not)
25 changes: 9 additions & 16 deletions jarbas/frontend/elm/Reimbursement/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -414,26 +414,19 @@ loadReimbursements lang apiKey query =

{-| Convert a list of key/value query pairs to a valid URL:
>>> toUrl [ ( "year", "2016" ), ( "foo", "bar" ) ]
"#/year/2016"
>>> toUrl [ ( "foo", "bar" ) ]
""
>>> toUrl [ ( "year", "2016" ), ( "month", "10" ) ]
"#/year/2016/month/10"
-}
toUrl : List ( String, String ) -> String
toUrl query =
let
validQueries =
List.filter (Tuple.first >> String.isEmpty >> not) query
in
if List.isEmpty validQueries then
""
else
validQueries
|> List.map (\( key, value ) -> key ++ "/" ++ value)
|> String.join "/"
|> (++) "#/"
if List.isEmpty query then
""
else
query
|> List.map (\( key, value ) -> key ++ "/" ++ value)
|> String.join "/"
|> (++) "#/"


updateJumpTo : Model -> Maybe Int -> ( Model, Cmd Msg )
Expand Down
6 changes: 3 additions & 3 deletions jarbas/frontend/tests/elm-doc-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
"Reimbursement.Company.View",
"Reimbursement.Decoder",
"Reimbursement.Fields",
"Reimbursement.Inputs.Model",
"Reimbursement.Inputs.Update",
"Reimbursement.Inputs.View",
"Reimbursement.Map.Model",
"Reimbursement.Map.Update",
"Reimbursement.Map.View",
Expand All @@ -36,6 +33,9 @@
"Reimbursement.SameDay.View",
"Reimbursement.SameSubquota.Update",
"Reimbursement.SameSubquota.View",
"Reimbursement.Search.Model",
"Reimbursement.Search.Update",
"Reimbursement.Search.View",
"Reimbursement.Update",
"Reimbursement.View",
"Update",
Expand Down

0 comments on commit 286a703

Please sign in to comment.