selection.js 979 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import assert from 'assert';
  2. import { StoreWrapper } from 'misago/services/store';
  3. import reducer, { all, none, item } from 'misago/reducers/selection';
  4. let store = null;
  5. describe("Selection", function() {
  6. beforeEach(function() {
  7. store = new StoreWrapper();
  8. store.addReducer('selection', reducer, []);
  9. store.init();
  10. });
  11. it("all", function() {
  12. store.dispatch(all([1, 2, 3]));
  13. assert.deepEqual(store.getState().selection, [1, 2, 3],
  14. "all() replaces state with new one");
  15. });
  16. it("none", function() {
  17. store.dispatch(all([1, 2, 3]));
  18. store.dispatch(none());
  19. assert.deepEqual(store.getState().selection, [],
  20. "none() replaces state with empty one");
  21. });
  22. it("item", function() {
  23. store.dispatch(item(2));
  24. assert.deepEqual(store.getState().selection, [2],
  25. "item(2) toggles item in");
  26. store.dispatch(item(2));
  27. assert.deepEqual(store.getState().selection, [],
  28. "item(2) toggles item out");
  29. });
  30. });