File: test/assert.js

Recommend this page to a friend!
  Classes of Harcharan Singh   Node Input Validator   test/assert.js   Download  
File: test/assert.js
Role: Example script
Content type: text/plain
Description: Example script
Class: Node Input Validator
Validate submitted input values in Node.js
Author: By
Last change:
Date: 2 years ago
Size: 527 bytes
 

Contents

Class file image Download
const assert = require('assert'); const niv = require('../lib/index'); describe('Assert Rules', () => { it('should pass with valid rule', async () => { niv.assert({ password: 'required|string', }); }); it('should throw exception for non existing rule', async () => { try { niv.assert({ password: 'passIt', }); throw new Error('Invalid seed exception.'); } catch (e) { assert.equal(e, 'Error: Rule passIt used for attribute password is invalid.'); } }); });