Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix test for useReducer, simpleCounter example #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
kentcdodds merged 1 commit into epicweb-dev:main from tsargent:fix-test
May 21, 2021
Merged

fix test for useReducer, simpleCounter example #139

kentcdodds merged 1 commit into epicweb-dev:main from tsargent:fix-test
May 21, 2021

Conversation

@tsargent
Copy link
Contributor

@tsargent tsargent commented May 21, 2021

The code that looks for "commentLessLines" ends up filtering unintended lines . Counter.toString() returns this:

function Counter({
 initialCount = 0,
 step = 1
 }) {
 // 🐨 replace React.useState with React.useReducer.
 // 💰 React.useReducer(countReducer, initialCount)
 const [count, setCount] = React.useReducer(countReducer, initialCount); // 💰 you can write the countReducer function so you don't have to make any
 // changes to the next two lines of code! Remember:
 // The 1st argument is called "state" - the current value of count
 // The 2nd argument is called "newState" - the value passed to setCount
 
 const increment = () => setCount(count + step);
 
 return /*#__PURE__*/(0, _jsxDevRuntime.jsxDEV)("button", {
 onClick: increment,
 children: count
 }, void 0, false, {
 fileName: _jsxFileName,
 lineNumber: 18,
 columnNumber: 10
 }, this);
 }

As you can see, the non-comment code with React.useReducer is on a line that ends with a comment, but this whole line will be filtered out, and the test will fail. We might want to instead look for lines that begin with comments: l.trim().substr(0, 2).includes('//')

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Thanks! This test is pretty bad 😅

@kentcdodds kentcdodds merged commit cc4971a into epicweb-dev:main May 21, 2021
Copy link
Member

@all-contributors please add @tsargent for tests

Copy link
Contributor

@kentcdodds

I've put up a pull request to add @tsargent! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kentcdodds kentcdodds kentcdodds approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /