5.1.2 • Published 9 years ago

chai-public-equal v5.1.2

Weekly downloads
4
License
ISC
Repository
github
Last release
9 years ago

chai-public-equal

"publicEqual" is an object properties matcher for Chai assertion library

This plugin use https://www.npmjs.com/package/deep-equal to check equality. Before compare it removes the private properties based on the given patterns. The default pattern is /^_.+/

Installation

npm install --save-dev chai-public-equal

Usage

var chai = require('chai');
var chaiPublicEqual = require('chai-public-equal');
chai.use(chaiPublicEqual());

Public Equal check

in your spec.js

var obj = {
	a: 'b',
	c: 'd',
	_d: 'private_value',
	e: {
	  f: 1,
	  _g: 2
	}
};
	
expect(obj).to.publicEql({
	a: 'b',
	c: 'd',
	_d: 'other_private_value',
	e: {
	  f: 1,
	  _h: 9
  }	  
});
//or with 'not'
expect(obj).to.not.publicEql({
	h: 'b'
});

Contain publics check

in your spec.js

var obj = {
	a: 'b',
	c: 'd',
	_d: 'private_value',
};
	
expect(obj).to.containPublics({
	a: 'b',
	_d: 'other_private_value'
});

//or with 'not'
expect(obj).to.not.containPublics({
	h: 'b'
});

Custom patterns for public property name checking

chai.use(chaiPublicEqual([/^_.+/, /^should/]));

5.1.2

9 years ago

5.1.1

9 years ago

5.1.0

9 years ago

5.0.0

9 years ago

4.1.1

9 years ago

4.1.0

9 years ago

4.0.5

9 years ago

4.0.4

9 years ago

4.0.3

9 years ago

4.0.2

9 years ago

4.0.1

9 years ago

4.0.0

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago