|
1 | 1 | import test from 'ava'; |
| 2 | + |
2 | 3 | import rules from '../../lib/rules/availableRules'; |
3 | 4 |
|
4 | 5 | test('rules endWithDot', (t) => { |
5 | | - const endWithDot = rules.endWithDot.check('input with dot.'); |
6 | | - const endWithoutDot = rules.endWithDot.check('input with dot'); |
7 | | - t.deepEqual(endWithDot, false); |
8 | | - t.deepEqual(endWithoutDot, true); |
| 6 | + const rulesObj = { |
| 7 | + 'end-with-dot': false, |
| 8 | + }; |
| 9 | + const endWithDot = rules.endWithDot('input with dot.', { rules: rulesObj }).check(); |
| 10 | + const endWithoutDot = rules.endWithDot('input with dot', { rules: rulesObj }).check(); |
| 11 | + |
| 12 | + t.false(endWithDot); |
| 13 | + t.true(endWithoutDot); |
9 | 14 | }); |
10 | 15 |
|
11 | 16 | test('rules minChar', (t) => { |
12 | | - const notMinChar = rules.minChar.check('less'); |
13 | | - const minChar = rules.minChar.check('this are more than 10 characters'); |
14 | | - t.deepEqual(notMinChar, false); |
15 | | - t.deepEqual(minChar, true); |
| 17 | + const rulesObj = { |
| 18 | + 'min-char': 10, |
| 19 | + }; |
| 20 | + const notMinChar = rules.minChar('less', { rules: rulesObj }).check(); |
| 21 | + const minChar = rules.minChar('this are more than 10 characters', { rules: rulesObj }).check(); |
| 22 | + |
| 23 | + t.false(notMinChar); |
| 24 | + t.true(minChar); |
16 | 25 | }); |
17 | 26 |
|
18 | 27 | test('rules mxChar', (t) => { |
19 | | - const moreThanMaxChar = rules.maxChar.check('this are more than 72 characters, believe me or not but the value moreThanMaxChar will be false ;-P'); |
20 | | - const lessThanMaxChar = rules.maxChar.check('this are less than 72 characters'); |
21 | | - t.deepEqual(moreThanMaxChar, false); |
22 | | - t.deepEqual(lessThanMaxChar, true); |
| 28 | + const rulesObj = { |
| 29 | + 'max-char': 72, |
| 30 | + }; |
| 31 | + const moreThanMaxChar = rules.maxChar('this are more than 72 characters, believe me or not but the value moreThanMaxChar will be false ;-P', { rules: rulesObj }).check(); |
| 32 | + const lessThanMaxChar = rules.maxChar('this are less than 72 characters', { rules: rulesObj }).check(); |
| 33 | + |
| 34 | + t.false(moreThanMaxChar); |
| 35 | + t.true(lessThanMaxChar); |
23 | 36 | }); |
0 commit comments