Sha256: 2557585f89a2543993060a9c998190e0751793450f09aa3d43531d21f1a46c3d
Contents?: true
Size: 953 Bytes
Versions: 16
Compression:
Stored size: 953 Bytes
Contents
/*! * Should * Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca> * MIT Licensed */ var util = require('../util'), eql = require('../eql'); module.exports = function(should, Assertion) { var i = should.format; Assertion.add('include', function(obj, description) { if(!Array.isArray(this.obj) && !util.isString(this.obj)) { this.params = { operator: 'to include an object equal to ' + i(obj), message: description }; var cmp = {}; for(var key in obj) cmp[key] = this.obj[key]; this.assert(eql(cmp, obj)); } else { this.params = { operator: 'to include ' + i(obj), message: description }; this.assert(~this.obj.indexOf(obj)); } }); Assertion.add('includeEql', function(obj, description) { this.params = { operator: 'to include an object equal to ' + i(obj), message: description }; this.assert(this.obj.some(function(item) { return eql(obj, item); })); }); };
Version data entries
16 entries across 16 versions & 1 rubygems