UNPKG

cheke

Version:

Express request validator with object's style response body and inspired by Laravel's Validator

36 lines (30 loc) 917 B
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); }); });