Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Fill history and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
btd committed Aug 10, 2016
1 parent 5091f9c commit 55aa163
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
14 changes: 13 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
11.0.0 / 2016-08-10
===================

* From code extracted parts for traversing different types in similar way.
This allows from now easy extend library to almost any collection class.
Now should.js everywhere supports Set/Map/WeakSet/WeakMap.
* .empty() now uses new type adaptors
* brecking change in .keys()/.key() now checks only for passed keys also uses type adaptors - it can check for keys in Map/Set e.g
* Added .value(key, value) to assert if key-value object has such value with this key
* Added .size() to get size of collection, works also with type adaptors
* .containEql uses type adaptors and can check if something contained within collection or subpart of key-value object

10.0.0 / 2016-07-18
===================

Expand All @@ -16,7 +28,7 @@
9.0.0 / 2016-05-30
==================

* Set should.config values to be more obvious. Pls check breacking changes page for exact values.
* Set should.config values to be more obvious. Pls check brecking changes page for exact values.
* Add support for SIMD data types.
* Fixed minor bugs in .eql
* Allow to show all equality check fails in .eql
Expand Down
31 changes: 29 additions & 2 deletions lib/ext/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,14 @@ export default function(should, Assertion) {
}, true);

/**
* Asserts given object has exact keys. Compared to `properties`, `keys` does not accept Object as a argument.
* Asserts given object has such keys. Compared to `properties`, `keys` does not accept Object as a argument.
* When calling via .key current object in assertion changed to value of this key
*
* @name keys
* @alias Assertion#key
* @memberOf Assertion
* @category assertion property
* @param {...*} [keys] Keys to check
* @param {...*} keys Keys to check
* @example
*
* ({ a: 10 }).should.have.keys('a');
Expand Down Expand Up @@ -310,15 +311,41 @@ export default function(should, Assertion) {
this.assert(missingKeys.length === 0);
});


Assertion.add('key', function(key) {
this.have.keys(key);
this.obj = getValue(this.obj, key);
});

/**
* Asserts given object has such value for given key
*
* @name value
* @memberOf Assertion
* @category assertion property
* @param {*} key Key to check
* @param {*} value Value to check
* @example
*
* ({ a: 10 }).should.have.value('a', 10);
* (new Map([[1, 2]])).should.have.value(1, 2);
*/
Assertion.add('value', function(key, value) {
this.have.key(key).which.is.eql(value);
});

/**
* Asserts given object has such size.
*
* @name size
* @memberOf Assertion
* @category assertion property
* @param {number} s Size to check
* @example
*
* ({ a: 10 }).should.have.size(1);
* (new Map([[1, 2]])).should.have.size(1);
*/
Assertion.add('size', function(s) {
this.params = { operator: 'to have size ' + s };
size(this.obj).should.be.exactly(s);
Expand Down

0 comments on commit 55aa163

Please sign in to comment.