WikiEduDashboard: Write tests for Redux reducers that cover all action types and ensure that state is not mutated

The reducers that make up the main Redux reducer should all be pure functions that are free of side effects and do not mutate their inputs. This makes unit tests particularly easy to implement, but important for making sure we avoid state-mutation bugs.

The handful of existing specs in test/reducers offer clear examples for how individual actions can be tested for these reducers, with deepFreeze being called on the initial state to guarantee that nothing in the reducer is mutating it.

Choose one or more reducers, and add tests for the functionality of each action type supported by that reducer. This should be done one reducer per commit. If you’re working on this, please post a comment to say which reducer you’re working on, so that others can work on different reducers.

Ideally, the set of tests for each reducer will provide 100% coverage of that reducer. You can check the coverage by running npm test and then opening coverage/lcov-report/index.html, which includes coverages maps of each javascript file.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 25 (16 by maintainers)

Commits related to this issue

Most upvoted comments

I plan to work on the “notifications” reducer

hey! am working on the article_finder reducer

I’ll be writing tests for the persisted_course.js reducer to ensure 100% action coverage and prevent state mutations. I’ll open a pull request soon. Thanks!

Hi @ragesoss I would love to work on this

Per the issue instructions, please post which one you’re working on so that others can choose different reducers.

articles.js is what I want to work on now

Greetings, @ragesoss i will like to take the active_courses reducer,

@ragesoss I want to work for adding test for some of the reducers. Plz assign this issue to me.

@ragesoss can I work on adding some of the tests? I have set up the development environment (and opened a PR for #2197).

(GCI 2018)

I’ll be making tests for uploads.js