UNPKG

527 BJavaScriptView Raw
1const assert = require('assert');
2
3const niv = require('../lib/index');
4
5describe('Assert Rules', () => {
6 it('should pass with valid rule', async () => {
7 niv.assert({
8 password: 'required|string',
9 });
10 });
11
12 it('should throw exception for non existing rule', async () => {
13 try {
14 niv.assert({
15 password: 'passIt',
16 });
17
18 throw new Error('Invalid seed exception.');
19 } catch (e) {
20 assert.equal(e, 'Error: Rule passIt used for attribute password is invalid.');
21 }
22 });
23});