-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(numeric): adding numericGreaterThan condition operator
- Loading branch information
1 parent
7ceb06d
commit 01384d0
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { numericGreaterThan } from './numericGreaterThan'; | ||
|
||
describe('numericGreaterThan', () => { | ||
it('returns true', () => { | ||
expect(numericGreaterThan(7, 5)).toBeTruthy; | ||
expect(numericGreaterThan(8.2, 2.2)).toBeTruthy; | ||
expect(numericGreaterThan(Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER)).toBeTruthy; | ||
}); | ||
|
||
it('returns false', () => { | ||
expect(numericGreaterThan(5, 7)).toBeFalsy; | ||
expect(numericGreaterThan(-1, -1)).toBeFalsy; | ||
expect(numericGreaterThan(Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER)).toBeFalsy; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Numeric greater than matching. | ||
* | ||
* @since 4.6.0 | ||
* @category Numeric | ||
* @param {number} data The value to be compared. | ||
* @param {number} expected The expected value. | ||
* @returns {boolean} Returns `true` if `value` is greater than `expected value`. | ||
* @example | ||
* ```javascript | ||
* numericGreaterThan(6, 5) | ||
* // => true | ||
* | ||
* numericGreaterThan(4, 8) | ||
* // => false | ||
* ``` | ||
*/ | ||
export function numericGreaterThan(data: number, expected: number): boolean { | ||
return ( | ||
data > expected | ||
); | ||
} |