Skip to content

Commit

Permalink
Add test for halting conditionaly a stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaspar committed Mar 15, 2017
1 parent c08b3f3 commit 40f7fd0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions stream/tests/test-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,27 @@ o.spec("stream", function() {
o(b()).equals(undefined)
o(count).equals(0)
})
o("combine can conditionaly halt", function() {
var count = 0;
var halt = false;
var a = Stream(1);
var b = Stream.combine(function(a) {
if (halt) {
return Stream.HALT
}
return a()
}, [a])["fantasy-land/map"](function(a) {
count++
return a
})
o(b()).equals(1)
o(count).equals(1)
halt = true
count = 0
a(2)
o(b()).equals(1)
o(count).equals(0)
})
o("combine will throw with a helpful error if given non-stream values", function () {
var spy = o.spy()
var a = Stream(1)
Expand Down

0 comments on commit 40f7fd0

Please sign in to comment.