Skip to content

Conversation

@tsargent
Copy link
Contributor

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
@kentcdodds
Copy link
Member

@all-contributors please add @tsargent for tests

@allcontributors
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants