From 7563b726b84c528b8a57df1815c08ad4f639bfbf Mon Sep 17 00:00:00 2001 From: Amitai Burstein Date: Sat, 23 Dec 2023 18:52:39 +0200 Subject: [PATCH] Move test and apply to Bootstrap --- IHP/View/CSSFramework.hs | 4 ++-- Test/View/CSSFrameworkSpec.hs | 9 +++++++-- Test/View/FormSpec.hs | 13 ------------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/IHP/View/CSSFramework.hs b/IHP/View/CSSFramework.hs index 595818da4..0320bdea1 100644 --- a/IHP/View/CSSFramework.hs +++ b/IHP/View/CSSFramework.hs @@ -628,9 +628,9 @@ bootstrap4 = def [hsx|
{message}
|] styledValidationResult _ _ = mempty - styledSubmitButton cssFramework SubmitButton { label, buttonClass } = + styledSubmitButton cssFramework SubmitButton { label, buttonClass, buttonDisabled } = let className :: Text = cssFramework.styledSubmitButtonClass - in [hsx||] + in [hsx||] styledPagination :: CSSFramework -> PaginationView -> Blaze.Html styledPagination _ paginationView = diff --git a/Test/View/CSSFrameworkSpec.hs b/Test/View/CSSFrameworkSpec.hs index 524ab11ce..fbcde33f3 100644 --- a/Test/View/CSSFrameworkSpec.hs +++ b/Test/View/CSSFrameworkSpec.hs @@ -40,13 +40,15 @@ tests = do styledFlashMessage cssFramework cssFramework flashMessage `shouldRenderTo` "
You have successfully registered for an account
" describe "submit button" do - let submitButton = SubmitButton { label = "Save Project" , buttonClass = "my-custom-button" , cssFramework } + let submitButton = SubmitButton { label = "Save Project" , buttonClass = "my-custom-button" , cssFramework, buttonDisabled = False } it "should render" do styledSubmitButton cssFramework cssFramework submitButton `shouldRenderTo` "" it "should render with empty class" do styledSubmitButton cssFramework cssFramework (submitButton { buttonClass = "" }) `shouldRenderTo` "" + it "should render with disabled button" do + styledSubmitButton cssFramework cssFramework (submitButton { buttonDisabled = True }) `shouldRenderTo` "" describe "text field" do let baseTextField = FormField @@ -396,13 +398,16 @@ tests = do styledFlashMessage cssFramework cssFramework flashMessage `shouldRenderTo` "
You have successfully registered for an account
" describe "submit button" do - let submitButton = SubmitButton { label = "Save Project" , buttonClass = "my-custom-button" , cssFramework } + let submitButton = SubmitButton { label = "Save Project" , buttonClass = "my-custom-button" , cssFramework, buttonDisabled = False } it "should render" do styledSubmitButton cssFramework cssFramework submitButton `shouldRenderTo` "" it "should render with empty class" do styledSubmitButton cssFramework cssFramework (submitButton { buttonClass = "" }) `shouldRenderTo` "" + it "should render with disabled button" do + styledSubmitButton cssFramework cssFramework (submitButton { buttonDisabled = True }) `shouldRenderTo` "" + describe "text field" do let baseTextField = FormField diff --git a/Test/View/FormSpec.hs b/Test/View/FormSpec.hs index d3f06ed6b..7cc5d27bb 100644 --- a/Test/View/FormSpec.hs +++ b/Test/View/FormSpec.hs @@ -42,19 +42,6 @@ tests = do |] form `shouldRenderTo` "
" - it "should render a form with disabled button" do - context <- createControllerContext - let ?context = context - - let options formContext = formContext |> set #formMethod "GET" - - let form = formForWithOptions project options [hsx| - {textField #title} - {submitButton {buttonDisabled = True}} - |] - form `shouldRenderTo` "
" - - shouldRenderTo renderFunction expectedHtml = Blaze.renderMarkup renderFunction `shouldBe` expectedHtml createControllerContext :: IO ControllerContext