Sha256: 4dc28af5bb40f087e4108f78f0821e6e10601732e419b64b6e87418f030c1639

Contents?: true

Size: 1.29 KB

Versions: 119

Compression:

Stored size: 1.29 KB

Contents

var common = require('../common');
var assert = common.assert;
var fake = common.fake.create();
var DelayedStream = common.DelayedStream;
var Stream = require('stream').Stream;

(function testDelayEventsUntilResume() {
  var source = new Stream();
  var delayedStream = DelayedStream.create(source, {pauseStream: false});

  // delayedStream must not emit until we resume
  fake.expect(delayedStream, 'emit', 0);

  // but our original source must emit
  var params = [];
  source.on('foo', function(param) {
    params.push(param);
  });

  source.emit('foo', 1);
  source.emit('foo', 2);

  // Make sure delayedStream did not emit, and source did
  assert.deepEqual(params, [1, 2]);
  fake.verify();

  // After resume, delayedStream must playback all events
  fake
    .stub(delayedStream, 'emit')
    .times(Infinity)
    .withArg(1, 'newListener');
  fake.expect(delayedStream, 'emit', ['foo', 1]);
  fake.expect(delayedStream, 'emit', ['foo', 2]);
  fake.expect(source, 'resume');

  delayedStream.resume();
  fake.verify();

  // Calling resume again will delegate to source
  fake.expect(source, 'resume');
  delayedStream.resume();
  fake.verify();

  // Emitting more events directly leads to them being emitted
  fake.expect(delayedStream, 'emit', ['foo', 3]);
  source.emit('foo', 3);
  fake.verify();
})();

Version data entries

119 entries across 105 versions & 6 rubygems

Version Path
entangled-0.0.16 spec/dummy/public/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.15 spec/dummy/public/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.15 spec/dummy/public/node_modules/phantomjs/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.15 spec/dummy/public/node_modules/bower/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.14 spec/dummy/public/node_modules/phantomjs/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.14 spec/dummy/public/node_modules/bower/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.14 spec/dummy/public/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.13 spec/dummy/public/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.13 spec/dummy/public/node_modules/phantomjs/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.13 spec/dummy/public/node_modules/bower/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.12 spec/dummy/public/node_modules/bower/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.12 spec/dummy/public/node_modules/phantomjs/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.12 spec/dummy/public/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.11 spec/dummy/public/node_modules/bower/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.11 spec/dummy/public/node_modules/phantomjs/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.11 spec/dummy/public/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.10 spec/dummy/public/node_modules/bower/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.10 spec/dummy/public/node_modules/phantomjs/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js
entangled-0.0.10 spec/dummy/public/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js