SystemTickFeed.test.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {SYSTEM_TICK_INTERVAL, SystemTickFeed} from "lib/SystemTickFeed.jsm";
  2. import {actionTypes as at} from "common/Actions.jsm";
  3. describe("System Tick Feed", () => {
  4. let instance;
  5. let clock;
  6. beforeEach(() => {
  7. clock = sinon.useFakeTimers();
  8. instance = new SystemTickFeed();
  9. instance.store = {getState() { return {}; }, dispatch() {}};
  10. });
  11. afterEach(() => {
  12. clock.restore();
  13. });
  14. it("should create a SystemTickFeed", () => {
  15. assert.instanceOf(instance, SystemTickFeed);
  16. });
  17. it("should fire SYSTEM_TICK events at configured interval", () => {
  18. let expectation = sinon.mock(instance.store).expects("dispatch")
  19. .twice()
  20. .withExactArgs({type: at.SYSTEM_TICK});
  21. instance.onAction({type: at.INIT});
  22. clock.tick(SYSTEM_TICK_INTERVAL * 2);
  23. expectation.verify();
  24. });
  25. it("should not fire SYSTEM_TICK events after UNINIT", () => {
  26. let expectation = sinon.mock(instance.store).expects("dispatch")
  27. .never();
  28. instance.onAction({type: at.UNINIT});
  29. clock.tick(SYSTEM_TICK_INTERVAL * 2);
  30. expectation.verify();
  31. });
  32. });