to-have-property

0.2.2 • Public • Published

toHaveProperty npm Build Status

toHaveProperty matcher for Jasmine (http://jasmine.github.io/) to check whether object has property or not.

Installation

npm install to-have-property --save-dev

How to use

 
require('to-have-property');
 
it('should find property in object', function() {
    expect({ x: 10 }).toHaveProperty('x');
});
 
it('should find property in object and check is it equal to certain value', function() {
    expect({ y: 123}).toHaveProperty('y', 123);
});
 
it('should find properties in object and check are they equal to values', function() {
    expect({ x: 1, y: 2, z: 3}).toHaveProperties({'x': 1, 'y': 2});
});
 
it('should find all properties in object', function() {
    expect({ x: 1, y: 2, z: 3 }).toHaveProperties('x', 'y');
});
 
 

Package Sidebar

Install

npm i to-have-property

Weekly Downloads

2

Version

0.2.2

License

MIT

Last publish

Collaborators

  • hyzhak