Fix Stream.end() (#2369)

This commit is contained in:
Ivan Kupalov 2019-02-07 09:44:31 +01:00 committed by Isiah Meadows
parent 415862880d
commit 7eea1b1e62
2 changed files with 52 additions and 9 deletions

View file

@ -261,6 +261,15 @@ o.spec("stream", function() {
o(thrown.constructor === TypeError).equals(false)
o(spy.callCount).equals(0)
})
o("combine callback not called when child stream was ended", function () {
var spy = o.spy()
var a = Stream(1)
var b = Stream(2)
var mapped = Stream.combine(spy, [a, b])
mapped.end(true)
a(11)
o(spy.callCount).equals(1)
})
})
o.spec("lift", function() {
o("transforms value", function() {
@ -479,6 +488,12 @@ o.spec("stream", function() {
o(spy.callCount).equals(1)
})
o("ended stream works like a container", function() {
var stream = Stream(1)
stream.end(true)
stream(2)
o(stream()).equals(2)
})
})
o.spec("toJSON", function() {
o("works", function() {
@ -544,6 +559,14 @@ o.spec("stream", function() {
o(stream["fantasy-land/map"]).equals(stream.map)
})
o("mapping function is not invoked after ending", function () {
var stream = Stream(undefined)
var fn = o.spy()
var mapped = stream.map(fn)
mapped.end(true)
stream(undefined)
o(fn.callCount).equals(1)
})
})
o.spec("ap", function() {
o("works", function() {