6 kyu

PC upgrade specs using HOC in ReactJS

Description
Loading description...
React
Fundamentals
  • Please sign in or sign up to leave a comment.
  • TudorTacal Avatar

    Brilliant kata to get someone started with HOC's.

    It might be useful to write a test against hard coding 110 straight into the HOC instead of reading the value from the second parameter passed to withPriceModel.

    I enjoyed the atmosphere from the Code Dojo as well. Make sure you ping me again when you organise the next one ;)

  • blackdahila Avatar

    I think there should be a test spying on withPriceModel execution count. Some of the solutions I see here are creating new component on every render.

  • regisbsb Avatar

    I think I might have cheated as well. Maybe we should call withPriceModel ourselves in the test with diferent price increaments

    • richkotze Avatar

      I think you have solved the kata correctly, even using withProps from recompose.

      The only thing here is you have not learned to build your own HOC as recompose does that for you.

      The point of this kata is to help with getting started building your own HOC.

      That is good feedback, perhaps have a couple tests for the fake models to see if withPriceModel can handle different price increases.

  • regisbsb Avatar

    @richkotze Could you fix the sample test to change that the Pro model should increase by 60 not 50. Cheers.

  • shovelend Avatar

    The default solution throws the following error: Error: kata.js: Unexpected token (23:20). Could you modify the default setup to compile?

  • Voile Avatar

    Needs random tests.

  • emgordon154 Avatar

    These failed tests are mystifying me. The four tests each in "Display the basic model pc" and "Display the pro model pc" all pass (and so does "withPriceModel returns a function"), but the others all fail (all had returned undefined except the last one which had returned "p"). :/

    • richkotze Avatar

      What I will do is put descriptions in the assert of what is expected and this might help.

    • richkotze Avatar

      I've updated the assert descriptions, let me know if that helps you.

      Otherwise it might be best to show some code and I will try help.