-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Merge pull request #60 from pelias/rename-positive-to-non-negative
changed function name from `positive` to `nonnegative`
- Loading branch information
Showing
4 changed files
with
36 additions
and
3 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
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,32 @@ | ||
const valid = require('../../util/valid'); | ||
|
||
module.exports.tests = {}; | ||
|
||
module.exports.tests.nonnegative = (test) => { | ||
test('nonnegative should throw error if value is less than 0', (t) => { | ||
t.throws(valid.nonnegative().bind(null, -1), /invalid document type, expecting: 0 or a positive number, got: -1/); | ||
t.end(); | ||
}); | ||
|
||
test('nonnegative should not throw error if value is 0', (t) => { | ||
t.doesNotThrow(valid.nonnegative().bind(null, 0), '0 should be allowed'); | ||
t.end(); | ||
}); | ||
|
||
test('nonnegative should not throw error if value is greater than 0', (t) => { | ||
t.doesNotThrow(valid.nonnegative().bind(null, 1), '1 should be allowed'); | ||
t.end(); | ||
}); | ||
|
||
}; | ||
|
||
module.exports.all = (tape, common) => { | ||
|
||
function test(name, testFunction) { | ||
return tape(`valid: ${name}`, testFunction); | ||
} | ||
|
||
for( var testCase in module.exports.tests ){ | ||
module.exports.tests[testCase](test, common); | ||
} | ||
}; |
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