Socket
Socket
Sign inDemoInstall

chai-stream

Package Overview
Dependencies
3
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    chai-stream

Extends Chai with assertions about streams.


Version published
Weekly downloads
89
decreased by-73.43%
Maintainers
1
Install size
787 kB
Created
Weekly downloads
 

Readme

Source

chai-stream

Build Status npm version

Extends Chai with assertions about streams.

Install

Node.js

npm install --save-dev chai-stream

AMD

define(function(require, exports, module) {
  var chai = require('chai');
  var chaiStream = require('chai-stream');
  
  chai.use(chaiStream);
});

script tag

<script src="chai.js"></script>
<script src="chai-stream.js"></script>

Usage

BDD-Style

var chai = require('chai');
var chaiStream = require('chai-stream');
chai.use(chaiStream);

var expect = chai.expect;

describe('getMyStream', function() {
  it('should return a readable stream', function() {
    var stream = getMyStream();

    expect(stream).to.be.a.ReadableStream;
  });

  it('should return a stream that will end', function() {
    var stream = getMyStream();

    return expect(stream).to.end;
  });
});
expect(obj).to.be.a.Stream

Type: function(any)

This assertion check that the specified object have a pipe method. So, it pass streams that not inherit Node's Stream.

obj

Type: any

expect(obj).to.be.a.ReadableStream

Type: function(any)

This assertion check that the specified object have a pipe and resume method. So, it pass streams that not inherit Node's Stream.

obj

Type: any

expect(obj).to.be.a.WritableStream

Type: function(any)

This assertion check that the specified object have a pipe and write method. So, it pass streams that not inherit Node's Stream.

obj

Type: any

expect(obj).to.end

Type: function(any): Promise<void>

Returns a promise that fulfilled when a end event is fired. And this function force the stream to read (like piping with WritableStream).

obj

Type: any

waitUntilStreamEnd listen end or error event of the stream.

TDD-Style

var chai = require('chai');
var chaiStream = require('chai-stream');
chai.use(chaiStream);

var assert = chai.assert;

describe('getMyStream', function() {
  it('should return a readable stream', function() {
    var stream = getMyStream();

    assert.isReadableStream(stream);
  });

  it('should return a stream that will end', function() {
    var stream = getMyStream();

    return assert.streamWillEnd(stream);
  });
});
assert.isStream(obj)

Type: function(any)

This assertion check that the specified object have a pipe method. So, it pass streams that not inherit Node's Stream.

obj

Type: any

assert.isReadableStream(obj)

Type: function(any)

This assertion check that the specified object have a pipe and resume method. So, it pass streams that not inherit Node's Stream.

obj

Type: any

assert.isWritableStream(obj)

Type: function(any)

This assertion check that the specified object have a pipe and write method. So, it pass streams that not inherit Node's Stream.

obj

Type: any

assert.streamWillEnd(obj)

Type: function(any): Promise<void>

Returns a promise that fulfilled when a end event is fired. And this function force the stream to read (like piping with WritableStream).

obj

Type: any

waitUntilStreamEnd listen end or error event of the stream.

License

MIT (c) Kuniwak

Keywords

FAQs

Last updated on 31 Aug 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc