Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chai-subset-in-order

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-subset-in-order

Chai plugin to test matching subsets in the same order

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.8K
increased by26.15%
Maintainers
1
Weekly downloads
 
Created
Source

"containSubsetInOrder" object properties matcher for Chai assertion library

Installation

npm install --save-dev chai-subset-in-order

Usage

common.js

var chai = require('chai');
var chaiSubset = require('chai-subset-in-order');
chai.use(chaiSubset);

in your spec.js

var obj = {
	a: 'b',
	c: 'd',
	e: {
		foo: 'bar',
		baz: {
			qux: 'quux'
		}
	}
};
	
expect(obj).to.containSubsetInOrder({
	a: 'b',
	e: {
		baz: {
			qux: 'quux'
		}
	}
});
//or with 'not'
expect(obj).to.not.containSubsetInOrder({
	g: 'whatever'
});

Also works good with arrays and should interface

var list = [{a: 'a', b: 'b'}, {v: 'f', d: {z: 'g'}}];

list.should.containSubsetInOrder([{a:'a'}]); //Assertion error is not thrown
list.should.containSubsetInOrder([{a:'a',  b: 'b'}]); //Assertion error is not thrown

list.should.containSubsetInOrder([{a:'a', b: 'bd'}]);
/*throws
AssertionError: expected
[
    {
        "a": "a",
        "b": "b"
    },
    {
        "v": "f",
        "d": {
            "z": "g"
        }
    }
]
to contain subset 
[ { a: 'a', b: 'bd' } ]
*/

and with assert interface

assert.containSubsetInOrder({a: 1, b: 2}, {a: 1});

Keywords

FAQs

Package last updated on 22 Oct 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc