Created
September 18, 2015 10:59
-
-
Save cefn/a0e12f88ebd7917c4125 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Of course, these can't really be called tests, but they indicate the syntax which successfully produces console | |
//output validating the various referenced functions | |
it("Can create a stream", function(){ | |
var stream = makeStream(); | |
}); | |
it("Can log a stream", function(){ | |
var stream = makeStream(); | |
stream.log("Original"); | |
}); | |
it("Can filter a stream", function(){ | |
var stream = makeStream(); | |
stream.filter(function(value){ | |
return value < 3; | |
}); | |
stream.log("Filtered"); | |
}); | |
it("Can map a stream", function(){ | |
var stream = makeStream(); | |
stream.map(function(value){ | |
return value * 2; | |
}); | |
stream.log("Mapped"); | |
}); | |
it("Can flatten a stream", function(){ | |
var stream = new AS.Stream(); | |
stream.flatten(); | |
stream.log("Mapped"); | |
stream.in.emit(_.range(5)); | |
}); | |
it("Can concat a stream", function(){ | |
var stream = AS.concat([ | |
AS.sequence(_.range(10)), | |
AS.sequence(_.range(20,30)), | |
]); | |
stream.log("Concat"); | |
}); | |
it("Interval sends events", function(){ | |
var stream = AS.interval(1000,"Hello World"); | |
stream.take(10); | |
stream.log("Interval"); | |
return AS.promiseLast(stream); | |
}); | |
it("SampledBy is sane", function(){ | |
var source = AS.interval(1000,"Hello Source"); | |
var trigger = AS.interval(500,"Hello Trigger"); | |
var stream = AS.sample(source, trigger); | |
stream.take(10); | |
stream.log("SampledBy"); | |
return AS.promiseLast(stream); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment