postaljs/postal.when — pull request #4 by joashc (2014-10-24 05:20:10+00:00)
Title: Fixed Issue#3 and unit tests

Fixed [Issue #3](https://github.com/postaljs/postal.when/issues/3), and a few other issues preventing the unit tests from passing.

Before these changes, we get the `You can only make functions into Conduits` error, as mentioned in [Issue #3](https://github.com/postaljs/postal.when/issues/3).

> postal.when@0.2.0 test
> mocha ./spec/*.js
6 failing

1) postal.when when calling when with default behavior "before all" hook:
Error: You can only make functions into Conduits.
2) postal.when when calling when with default behavior "after all" hook:
TypeError: Cannot call method 'dispose' of undefined
3) postal.when when calling when with once = true "before all" hook:
Error: You can only make functions into Conduits.
4) postal.when when calling when with once = true "after all" hook:
TypeError: Cannot call method 'dispose' of undefined
5) postal.when when calling when with a timeout that triggers onError The onError callback should be invoked:
Error: You can only make functions into Conduits.
6) postal.when when calling when with a timeout that does NOT trigger onError data should match expected:
Error: You can only make functions into Conduits.

npm ERR! Test failed. See above for more details.

After adding no-op callbacks for subscriptions with undefined callbacks, and fixing a few other minor issues, all unit tests pass:

> postal.when@0.2.0 test
> mocha ./spec/*.js

postal.when
when calling when with default behavior
✓ should invoke the callback the expected number of times
✓ data_a should match expected
✓ data_b should match expected
✓ data_c should match expected
✓ data_d should match expected
when calling when with once = true
✓ should only invoke the callback once
✓ data_a should match expected
✓ data_b should match expected
✓ data_c should match expected
✓ data_d should match expected
when calling when with a timeout that triggers onError
✓ The onError callback should be invoked
when calling when with a timeout that does NOT trigger onError
✓ data should match expected (1111ms)

12 passing (1s)