Skip to content

Instantly share code, notes, and snippets.



Created Jun 22, 2015
What would you like to do?
Mocha test which successfully tests zipped stream (using onValues to force side effects).
var Bacon = require("baconjs"),
assert = require("assert");
describe("Testing stream equality logic", function(){
it( "can match Bacon streams backed by the same array.", function(){
var targetSequence = [
["oldmacdonald/farm", "['sheep','pig','cow','duck']" ] , //n.b. JSON.stringify of array
["oldmacdonald/farm/sheep", "'Baa'"] , //n.b. JSON.stringify of string (quoted)
["oldmacdonald/farm/pig", "'Oink'"] ,
["oldmacdonald/farm/cow", "'Moo'"] ,
["oldmacdonald/farm/duck", "'Quack'"] ,
var actualSequence = targetSequence.slice(0);
//adding lines below causes test to fail
//actualSequence.push(["oldmacdonald/farm/horse", "'Neigh'"]);
var targetStream = Bacon.sequentially(0, targetSequence);
var actualStream = Bacon.sequentially(0, actualSequence);
//var targetStream = Bacon.fromArray(targetSequence);
//var actualStream = Bacon.fromArray(actualSequence);
var deepEqual = function(target, actual){
console.log("Testing " + JSON.stringify(target) + " versus " + JSON.stringify(actual) + "...");
assert.deepEqual(target, actual);
return true;
var zippedStream = Bacon.zipAsArray(targetStream, actualStream);
return zippedStream.toPromise()
console.log("Stream finished");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment