Socket
Socket
Sign inDemoInstall

chai-immutable

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    chai-immutable

Chai assertions for Facebook's Immutable library for JavaScript collections


Version published
Weekly downloads
14K
increased by6.06%
Maintainers
1
Install size
15.5 kB
Created
Weekly downloads
 

Readme

Source

npm version License Build Status Coverage Status devDependency Status

Chai Immutable

This provide a set of Chai assertions for Facebook's Immutable library for JavaScript collections.

Installation

Install via npm:

npm install chai-immutable

You can then use this plugin as any other Chai plugins:

var chai = require('chai');
var chaiImmutable = require('chai-immutable');

chai.use(chaiImmutable);

API Reference

.empty

Asserts that the immutable collection is empty.

expect(List()).to.be.empty;
expect(List.of(1, 2, 3)).to.not.be.empty;

.equal(collection)

  • @param { Collection } collection

Asserts that the values of the target are equvalent to the values of collection. Aliases of Chai's original equal method are also supported.

var a = List.of(1, 2, 3);
var b = List.of(1, 2, 3);
expect(a).to.equal(b);

.size(value)

  • @param { Number } size

Asserts that the immutable collection's size property has the expected value.

expect(List.of(1, 2, 3)).to.have.size(3);

It can also be used as a chain precursor to a value comparison for the size property.

expect(List.of(1, 2, 3)).to.have.size.least(3);
expect(List.of(1, 2, 3)).to.have.size.most(3);
expect(List.of(1, 2, 3)).to.have.size.above(2);
expect(List.of(1, 2, 3)).to.have.size.below(4);
expect(List.of(1, 2, 3)).to.have.size.within(2,4);

Similarly to length/lengthOf, sizeOf can be used as an alias of size:

expect(List.of(1, 2, 3)).to.have.sizeOf(3);

Keywords

FAQs

Last updated on 07 Mar 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