Giter VIP home page Giter VIP logo

Comments (5)

dvdzkwsk avatar dvdzkwsk commented on March 29, 2024

Hm, are you exporting the HomeView component as a dumb component? If you're wanting to test how it renders with certain props you don't want to test the connected component, which is currently the only export: https://github.com/davezuko/react-redux-starter-kit/blob/example/todo-application/client/views/home.jsx

Edit: I guess I maybe misread your question, since you're talking about initial application state it seems, though I'm not sure how that influences the unit tests for HomeView. If what I mentioned above didn't help, could you clarify? Thanks!

from react-redux-starter-kit.

agdolla avatar agdolla commented on March 29, 2024

I rebased the branch and made all the modifications so the todo example works again, you can find it in my fork at: https://github.com/agdolla/react-redux-starter-kit/tree/example/todo-application
( I left two console.log in it intentionally)
so HomeView has this line:

const todos = this.props.todos.toJS();

When running the tests this line fails because this.props.todos is undefined.

I tried to pass todos as you can see in HomeView.spec.js:

beforeEach(function () {
  const createTodoItem = (copy) => Immutable.Map({
    copy     : copy,
    complete : false
  });
  const initialState = Immutable.List([
    'Read the docs',
    'Build something cool'
  ].map(createTodoItem));
  const props = {todos: initialState};
  component = shallowRenderWithProps(props);

If you try to run the tests you'll see two lines of console output, one with this.props.todos defined and one with undefined :(
Could you please try it ?

from react-redux-starter-kit.

dvdzkwsk avatar dvdzkwsk commented on March 29, 2024

Yeah I'll definitely take a look at this, though it might not be until later today. Thanks for this though, I appreciate all the work you're doing!

from react-redux-starter-kit.

dvdzkwsk avatar dvdzkwsk commented on March 29, 2024

Hey @agdolla, I tested out your branch and it looks like you just need to pass it in to the renderWithProps function:

// current
component = shallowRenderWithProps(props);
rendered  = renderWithProps();

// fixed
component = shallowRenderWithProps(props);
rendered  = renderWithProps(props);

Does that help at all?

from react-redux-starter-kit.

agdolla avatar agdolla commented on March 29, 2024

🐵 sure, I should've read the next line :)
thanks
I try to have a few tests then send you a new PR

from react-redux-starter-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.