@cycle/time
Advanced tools
Comparing version 0.6.1 to 0.7.0
@@ -20,5 +20,3 @@ "use strict"; | ||
var pendingAsserts = asserts.filter(function (assert) { return assert.state === 'pending'; }); | ||
if (pendingAsserts.length > 0) { | ||
pendingAsserts.forEach(function (assert) { return assert.finish(); }); | ||
} | ||
pendingAsserts.forEach(function (assert) { return assert.finish(); }); | ||
var failedAsserts = asserts.filter(function (assert) { return assert.state === 'failed'; }); | ||
@@ -32,3 +30,9 @@ var success = failedAsserts.length === 0; | ||
var error = combineErrors(errors); | ||
done(error); | ||
var usingJasmine = 'fail' in done; | ||
if (usingJasmine) { | ||
done.fail(error); | ||
} | ||
else { | ||
done(error); | ||
} | ||
} | ||
@@ -35,0 +39,0 @@ } |
"use strict"; | ||
require('setimmediate'); | ||
function processEvent(args) { | ||
var scheduler = args.scheduler, done = args.done, currentTime = args.currentTime, setTime = args.setTime, timeToRunTo = args.timeToRunTo; | ||
var nextEvent = scheduler.peek(); | ||
var outOfTime = nextEvent && timeToRunTo && nextEvent.time >= timeToRunTo; | ||
if (!nextEvent || outOfTime) { | ||
done(); | ||
return; | ||
} | ||
var eventToProcess = scheduler.shiftNextEntry(); | ||
if (eventToProcess.cancelled) { | ||
setImmediate(processEvent, args); | ||
return; | ||
} | ||
var time = eventToProcess.time; | ||
setTime(time); | ||
if (eventToProcess.f) { | ||
eventToProcess.f(eventToProcess, time, scheduler.add, currentTime); | ||
} | ||
if (eventToProcess.type === 'next') { | ||
eventToProcess.stream.shamefullySendNext(eventToProcess.value); | ||
} | ||
if (eventToProcess.type === 'error') { | ||
eventToProcess.stream.shamefullySendError(eventToProcess.error); | ||
} | ||
if (eventToProcess.type === 'complete') { | ||
eventToProcess.stream.shamefullySendComplete(); | ||
} | ||
setImmediate(processEvent, args); | ||
} | ||
function runVirtually(scheduler, done, currentTime, setTime, timeToRunTo) { | ||
if (timeToRunTo === void 0) { timeToRunTo = null; } | ||
function processEvent() { | ||
var nextEvent = scheduler.peek(); | ||
if (!nextEvent) { | ||
done(); | ||
return; | ||
} | ||
var outOfTime = timeToRunTo && nextEvent.time >= timeToRunTo; | ||
if (outOfTime) { | ||
done(); | ||
return; | ||
} | ||
var eventToProcess = scheduler.shiftNextEntry(); | ||
if (eventToProcess.cancelled) { | ||
setImmediate(processEvent); | ||
return; | ||
} | ||
var time = eventToProcess.time; | ||
setTime(time); | ||
if (eventToProcess.f) { | ||
eventToProcess.f(eventToProcess, time, scheduler.add, currentTime); | ||
} | ||
if (eventToProcess.type === 'next') { | ||
eventToProcess.stream.shamefullySendNext(eventToProcess.value); | ||
} | ||
if (eventToProcess.type === 'error') { | ||
eventToProcess.stream.shamefullySendError(eventToProcess.error); | ||
} | ||
if (eventToProcess.type === 'complete') { | ||
eventToProcess.stream.shamefullySendComplete(); | ||
} | ||
setImmediate(processEvent); | ||
} | ||
setImmediate(processEvent); | ||
var args = { scheduler: scheduler, done: done, currentTime: currentTime, setTime: setTime, timeToRunTo: timeToRunTo }; | ||
setImmediate(processEvent, args); | ||
} | ||
exports.runVirtually = runVirtually; |
{ | ||
"name": "@cycle/time", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "A time driver designed to enable awesome testing and dev tooling", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
61249
39
1215