Skip to content

Commit

Permalink
Fix typo and add missing type (#178)
Browse files Browse the repository at this point in the history
* Fix typo

* Add missing about assertion

* Update lib/index.d.ts

Co-authored-by: Jonas Pauthier <[email protected]>

Co-authored-by: Jonas Pauthier <[email protected]>
  • Loading branch information
hueniverse and Nargonath authored Nov 29, 2022
1 parent aa1f2b3 commit b4ffcec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,16 @@ declare namespace expect {
*/
above(value: T): Assertion<T>;

/**
* Asserts that the reference value is within a delta difference from the provided value.
*
* @param value - the value to compare to.
* @param delta - the delta +/- range value.
*
* @returns assertion chain object.
*/
about(value: T, delta: number): Assertion<T>;

/**
* Asserts that the reference value is greater than (>) the provided value.
*
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,15 @@ internals.between = function (from, to) {
internals.addMethod('between', internals.between);


internals.above = function (value, delta) {
internals.about = function (value, delta) {

internals.assert(this, internals.type(this._ref) === 'number', 'Can only assert about on numbers');
internals.assert(this, internals.type(value) === 'number' && internals.type(delta) === 'number', 'About assertion requires two number arguments');

return this.assert(Math.abs(this._ref - value) <= delta, 'be about ' + value + ' \u00b1' + delta);
};

internals.addMethod('about', internals.above);
internals.addMethod('about', internals.about);


internals.instanceof = function (type) {
Expand Down

0 comments on commit b4ffcec

Please sign in to comment.