stream-mock
Node stream mock module
Last updated 7 years ago by banst .
MIT · Repository · Original npm · Tarball · package.json
$ npm install stream-mock 
SYNC missed versions from official npm registry.

Stream Mock

Travis (.org) npm Snyk Vulnerabilities for GitHub Repo Code Climate coverage Code Climate maintainability Greenkeeper badge node npm type definitions GitHub

Mock nodejs streams.

Features

Quick start

yarn add stream-mock

Or, if you are more a npm person

npm i stream-mock

Basic usage

You are building an awesome brand new Transform stream that rounds all your values.

import { Transform } from 'stream';

export default class Rounder extends Transform {
  _transform(chunk, encoding, callback) {
    this.push(Math.round(chunk));
    callback();
  }
}

Now you need / want to test it.

import { ObjectReadableMock, ObjectWritableMock } from 'stream-mock';
import chai from 'chai';

import Rounder from 'the/seven/bloody/hells';

chai.should();

describe('Test me if you can', (done) => {
    it('Round me like one of your french girls', {
        // Given
        const input = [1.2, 2.6, 3.7];
        const transform = new Rounder({objectMode: true});
        const reader = new ObjectReadableMock(input);
        const writer = new ObjectWritableMock();
        // When
        reader.pipe(transform).pipe(writer);
        // Then
        writer.on('finish', ()=>{
            writer.data.should.deep.equal(input.map(Math.round));
        })
    });
});

magic

API documentation

Full API doc is hosted here


License

MIT

Current Tags

  • 2.0.5                                ...           latest (5 years ago)

10 Versions

  • 2.0.5                                ...           5 years ago
  • 2.0.4                                ...           5 years ago
  • 2.0.3                                ...           5 years ago
  • 2.0.2                                ...           6 years ago
  • 2.0.1                                ...           6 years ago
  • 1.2.0                                ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.2                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Total 3
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (1)
Dev Dependencies (21)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE