Skip to content
This repository was archived by the owner on Sep 25, 2019. It is now read-only.

fix(challenges): fix third test for template literals#192

Merged
scissorsneedfoodtoo merged 2 commits intofreeCodeCamp:devfrom
johnkennedy9147:fix-template-literals-test-3
Jul 31, 2018
Merged

fix(challenges): fix third test for template literals#192
scissorsneedfoodtoo merged 2 commits intofreeCodeCamp:devfrom
johnkennedy9147:fix-template-literals-test-3

Conversation

@johnkennedy9147
Copy link
Copy Markdown
Contributor

Description

replaced the overly long and complex regex which tests for use of template literals with a much
simpler one that has the same effect

also fixed \n not being displayed as it was not escaped or surrounded by code tags

ISSUES CLOSED: #135

Pre-Submission Checklist

  • Your pull request targets the dev branch.
  • Branch starts with either fix/, feature/, or translate/ (e.g. fix/challenge-tests)
  • All new and existing tests pass the command npm test.
  • Use npm run commit to generate a conventional commit message.
    Learn more here: https://conventionalcommits.org/#why-use-conventional-commits
  • The changes were done locally on your machine and NOT GitHub web interface.
    If they were done on the web interface you have ensured that you are creating conventional commit messages.

Checklist:

  • Tested changes locally.
  • Addressed currently open issue (replace XXXXX with an issue no in next line)

Closes #135

replaced the overly long and complex regex which tests for use of template literals with a much
simpler one that has the same effect

ISSUES CLOSED: #135
@scissorsneedfoodtoo
Copy link
Copy Markdown
Contributor

@johnkennedy9147, thank you for continuing to improve this problem! I just found a couple of small things I'll leave as a review.

"A lot of things happened there.",
"Firstly, the example uses backticks (<code>`</code>), not quotes (<code>'</code> or <code>\"</code>), to wrap the string.",
"Secondly, notice that the string is multi-line, both in the code and the output. This saves inserting \n within strings.",
"Secondly, notice that the string is multi-line, both in the code and the output. This saves inserting <code>\n</code> within strings.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested this locally and it seems like \n still needs to be escaped, whether or not it's wrapped in <code> tags. <code>\\n<code> gets it to show up locally on Learn for me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry forgot to escape the \ will fix

"text": "Template strings were used",
"testString":
"getUserInput => assert(getUserInput('index').match(/`<li \\s*class\\s*=\\s*(\"\\s*text-warning\\s*\"|'\\s*text-warning\\s*')\\s*>\\s*\\$\\s*\\{(\\s*\\w+\\s*|\\s*\\w+\\s*\\[\\s*[\\w]+\\s*\\]\\s*)\\}\\s*<\\s*\\/li\\s*>`/g), 'Template strings were used');"
"getUserInput => assert(getUserInput('index').match(/`.*`/g), 'Template strings were used');"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unfortunately it seems like the commented out section is causing this to pass. I like your simplified test much more than the last one, so how about changing the commented out section?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not finding that to be the case.

image

unless camper manually adds backticks to the comment

image

@raisedadead raisedadead added status: ready for QA To be applied to PR that are ready for QA. status: needs update To be applied to PR if a maintainer/reviewer has left a feedback and follow up is needed from OP. and removed status: ready for QA To be applied to PR that are ready for QA. labels Jul 30, 2018
 and test error message
@johnkennedy9147 johnkennedy9147 added status: ready for QA To be applied to PR that are ready for QA. and removed status: needs update To be applied to PR if a maintainer/reviewer has left a feedback and follow up is needed from OP. labels Jul 30, 2018
@scissorsneedfoodtoo scissorsneedfoodtoo merged commit fd8c9e4 into freeCodeCamp:dev Jul 31, 2018
@scissorsneedfoodtoo
Copy link
Copy Markdown
Contributor

@johnkennedy9147, thank you for all of your hard work here. Everything LGTM!

@johnkennedy9147 johnkennedy9147 deleted the fix-template-literals-test-3 branch July 31, 2018 10:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

status: ready for QA To be applied to PR that are ready for QA.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Multiple Issues with tests for ES6: Create Strings using Template Literals

3 participants