Add SchemaVersion
type
This commit is contained in:
parent
add4b11df3
commit
e9e46464c2
2 changed files with 30 additions and 0 deletions
5
js/modules/types/schema_version.js
Normal file
5
js/modules/types/schema_version.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
const isNumber = require('lodash/isNumber');
|
||||
|
||||
|
||||
exports.isValid = value =>
|
||||
isNumber(value) && value >= 0;
|
25
test/modules/types/schema_version_test.js
Normal file
25
test/modules/types/schema_version_test.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
require('mocha-testcheck').install();
|
||||
const { assert } = require('chai');
|
||||
|
||||
const SchemaVersion = require('../../../js/modules/types/schema_version');
|
||||
|
||||
|
||||
describe('SchemaVersion', () => {
|
||||
describe('isValid', () => {
|
||||
check.it(
|
||||
'should return true for positive integers',
|
||||
gen.posInt,
|
||||
(input) => {
|
||||
assert.isTrue(SchemaVersion.isValid(input));
|
||||
}
|
||||
);
|
||||
|
||||
check.it(
|
||||
'should return false for any other value',
|
||||
gen.primitive.suchThat(value => typeof value !== 'number' || value < 0),
|
||||
(input) => {
|
||||
assert.isFalse(SchemaVersion.isValid(input));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue