Created
June 22, 2015 08:56
-
-
Save cefn/9633e715b6677600b5eb to your computer and use it in GitHub Desktop.
Mocha Test of .zip laziness
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
var Bacon = require("baconjs"), | |
assert = require("assert"); | |
require('promise.prototype.finally'); | |
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); | |
actualSequence.push(["oldmacdonald/farm/horse", "'Neigh'"]); | |
var targetStream = Bacon.fromArray(targetSequence); | |
var actualStream = Bacon.fromArray(actualSequence); | |
//var targetStream = Bacon.sequentially(0, targetSequence); | |
//var actualStream = Bacon.sequentially(0, actualSequence); | |
var deepEqual = function(target, actual){ | |
console.log("Testing " + JSON.stringify(target) + " versus " + JSON.stringify(actual) + "..."); | |
assert.deepEqual(target, actual); | |
return true; | |
}; | |
var receivePromise = targetStream.zip(actualStream, deepEqual) | |
.toPromise() | |
.finally(function(){ | |
console.log("Stream finished"); | |
}); | |
return receivePromise; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment