Skip to content

Commit

Permalink
Merge pull request #10 from oesukam/ft-integer-validation-164470111
Browse files Browse the repository at this point in the history
#164470111 Add integer's validation
  • Loading branch information
oesukam committed Mar 7, 2019
2 parents 18e1941 + 5a2bc59 commit 79e296f
Show file tree
Hide file tree
Showing 11 changed files with 368 additions and 26 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
7 changes: 7 additions & 0 deletions __tests__/messages/notIntegerMessage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const notInteger = require('../../src/messages/notIntegerMessage');

describe('not-an-integer-message', () => {
test('should return The age must be an integer.', () => {
expect(notInteger('age')).toBe('The age must be an integer.');
});
});
4 changes: 2 additions & 2 deletions __tests__/messages/notNumberMessage.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const notNumber = require('../../src/messages/notNumberMessage');

describe('not-a-number-message', () => {
test('should return The username must be a number.', () => {
expect(notNumber('username')).toBe('The username must be a number.');
test('should return The age must be a number.', () => {
expect(notNumber('age')).toBe('The age must be a number.');
});
});
35 changes: 35 additions & 0 deletions __tests__/validators/integer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const integer = require('../../src/validators/integer');

describe('integer-validator', () => {
test('should return The undefined must be an integer.', () => {
expect(integer()).toBe('The undefined must be an integer.');
});

test('should return The age must be an integer.', () => {
expect(integer({
value: 'not an integer',
label: 'age',
}),).toBe('The age must be an integer.');
});

test('should return The age must be an integer.', () => {
expect(integer({
value: '21',
label: 'age',
}),).toBe('The age must be an integer.');
});

test('should return The age must be an integer.', () => {
expect(integer({
value: 25.5,
label: 'age',
}),).toBe('The age must be an integer.');
});

test('should return false', () => {
expect(integer({
value: 21,
label: 'age',
}),).toBe(false);
});
});
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
testEnvironment: 'node',
clearMocks: true,
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: ['node_modules', 'src/index.js'],
coveragePathIgnorePatterns: ['node_modules', 'lib', 'src/index.js'],
verbose: true,
coverageThreshold: {
global: {
Expand Down

0 comments on commit 79e296f

Please sign in to comment.