Skip to content

Conversation

@eahlberg
Copy link
Contributor

@eahlberg eahlberg commented Oct 11, 2022

Fixes #1784

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

, htmlNoneContain
, htmlAllContainPreEscaped
, htmlAnyContainPreEscaped
, htmlNoneContainPreEscaped
Copy link
Contributor Author

@eahlberg eahlberg Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

html*PreEscaped preferable to e.g. html*ContainRaw? PreEscaped was used since that's what it's called in the Blaze docs.

get ("/html" :: Text)
statusIs 200
htmlAnyContainPreEscaped "meta" "content=\"site description\""
htmlAllContainPreEscaped "meta" "content=\"site description"
Copy link
Contributor Author

@eahlberg eahlberg Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice if there are more concise examples than this but I couldn't come up with any

case matches of
[] -> failure $ "Nothing matched css query: " <> query
_ -> liftIO $ HUnit.assertBool ("Not all "++T.unpack query++" contain "++search ++ " matches: " ++ show matches) $
DL.all (DL.isInfixOf search) (map (TL.unpack . decodeUtf8) matches)
Copy link
Contributor Author

@eahlberg eahlberg Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for the escaping, this is the exact same code as htmlAllContain, should we refactor this?

@eahlberg eahlberg force-pushed the html-contain-match-raw-string branch from 03184b6 to 9b44e8c Compare October 12, 2022 08:06
statusIs 200
htmlAnyContainPreEscaped "meta" "content=\"site description\""
htmlAllContainPreEscaped "meta" "content=\"site description"
htmlNoneContainPreEscaped "meta" "foobar"
Copy link
Contributor Author

@eahlberg eahlberg Oct 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks absence in the same was as the test for htmlNoneContain, I think it'd be better with a test case which illustrates the difference between the two functions.

@eahlberg eahlberg marked this pull request as ready for review October 12, 2022 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[yesod-test] bring back support for matching of preescaped strings

1 participant