kentcdodds / advanced-react-patterns-v2

Created with CodeSandbox
https://codesandbox.io/s/github/kentcdodds/advanced-react-patterns-v2
1.51k stars 568 forks source link

Add toggle back spec for exercise 01 #60

Closed norchow closed 5 years ago

norchow commented 5 years ago

Hi,

Doing the training at Frontend Masters, i run into an issue where my code passed the spec but it wasn't working as expected.

Basically, if in exercise one, you don't toggle the on value, but you just set it to true, the tests were passing. The solution could look like:

toggle = () => {
    this.setState(
      currentState => ({
        on: true,
      }),
      () => this.props.onToggle(this.state.on),
    )
  }

I've just added a new spec, to test this behaviour. Let me know what you think.

codecov[bot] commented 5 years ago

Codecov Report

Merging #60 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #60   +/-   ##
=======================================
  Coverage   39.67%   39.67%           
=======================================
  Files          22       22           
  Lines         431      431           
  Branches       66       66           
=======================================
  Hits          171      171           
  Misses        217      217           
  Partials       43       43

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 944d371...23cf88e. Read the comment docs.

kentcdodds commented 5 years ago

@all-contributors please add @norchow for tests

allcontributors[bot] commented 5 years ago

@kentcdodds

I've put up a pull request to add @norchow! :tada: