Actions generate events that stores are listening to. Basically, your test runs too fast.
Usually in my tests, I assume that Reflux will do what it does right, and I call the listener function directly. You want to add a few more statements to make sure that Reflux is connected correctly.
it("is configured", function () { expect(AppStore.listenables).to.include(AppActions); expect(AppActions.fooAction).to.be.a('function'); }); it("toggles foo", function () { expect(AppStore.foo).to.equal(false); AppStore.onFooAction(); expect(AppStore.foo).to.equal(true); });
Another way to check this is with a timeout, but I feel dirty when I add timeouts inside the tests.
it("toggles foo", function (done) { expect(AppStore.foo).to.equal(false); AppStore.listenables[0].fooAction(); setTimeout(function () { try { expect(AppStore.foo).to.equal(true); done(); } catch (e) { done(e); } }, 15); });
source share