implemented Handlers.incAnchorBy
This commit is contained in:
parent
994e2777c3
commit
89879153de
|
@ -31,6 +31,7 @@ module Helpers (
|
||||||
editParam,
|
editParam,
|
||||||
editAnchor,
|
editAnchor,
|
||||||
incParamBy,
|
incParamBy,
|
||||||
|
incAnchorBy,
|
||||||
incStrBy
|
incStrBy
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
@ -145,6 +146,15 @@ incParamBy
|
||||||
-> Maybe Url
|
-> Maybe Url
|
||||||
incParamBy n p = editParam p $ incStrBy n
|
incParamBy n p = editParam p $ incStrBy n
|
||||||
|
|
||||||
|
-- | Increment an anchor by a given amount (if possible)
|
||||||
|
incAnchorBy
|
||||||
|
:: Integer
|
||||||
|
-- ^ the amount to increment by
|
||||||
|
-> Url
|
||||||
|
-- ^ the 'Url' to edit
|
||||||
|
-> Maybe Url
|
||||||
|
incAnchorBy n = editAnchor $ incStrBy n
|
||||||
|
|
||||||
-- | Increment a 'String' representation of an 'Integer' by a given
|
-- | Increment a 'String' representation of an 'Integer' by a given
|
||||||
-- amount (if possible)
|
-- amount (if possible)
|
||||||
incStrBy
|
incStrBy
|
||||||
|
|
|
@ -39,6 +39,7 @@ spec = do
|
||||||
editParamSpec
|
editParamSpec
|
||||||
editAnchorSpec
|
editAnchorSpec
|
||||||
incParamBySpec
|
incParamBySpec
|
||||||
|
incAnchorBySpec
|
||||||
incStrBySpec
|
incStrBySpec
|
||||||
|
|
||||||
textToUrlSpec :: Spec
|
textToUrlSpec :: Spec
|
||||||
|
@ -194,6 +195,22 @@ incParamBySpec = describe "incParamBy" $ mapM_
|
||||||
, ( "c", Just "foo" )
|
, ( "c", Just "foo" )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
incAnchorBySpec :: Spec
|
||||||
|
incAnchorBySpec = describe "incAnchorBy" $ mapM_
|
||||||
|
( \(desc, n, url, expected) -> context desc $
|
||||||
|
it ("should be " ++ show expected) $
|
||||||
|
incAnchorBy n url `shouldBe` expected
|
||||||
|
)
|
||||||
|
|
||||||
|
-- description, number, url, expected
|
||||||
|
[ ( "+1", 1, urlWith "1", Just $ urlWith "2" )
|
||||||
|
, ( "+2", 2, urlWith "1", Just $ urlWith "3" )
|
||||||
|
, ( "empty", 1, simpleUrl, Just simpleUrl )
|
||||||
|
, ( "non-numeric", 1, urlWith "foo", Nothing )
|
||||||
|
]
|
||||||
|
|
||||||
|
where urlWith str = simpleUrl { anchor = Just str }
|
||||||
|
|
||||||
incStrBySpec :: Spec
|
incStrBySpec :: Spec
|
||||||
incStrBySpec = describe "incStrBy" $ mapM_
|
incStrBySpec = describe "incStrBy" $ mapM_
|
||||||
( \(n, str, expected) ->
|
( \(n, str, expected) ->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user