-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
28 lines (22 loc) · 1.05 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import test from 'ava';
import paragraph from './index.js';
test('paragraph return type to be string', t => {
t.is(typeof paragraph(), 'string');
});
test('paragraph sentences count is 10', t => {
t.is(paragraph().split('. ').length, 10);
});
test('paragraph sentences count is 5', t => {
t.is(paragraph({sentences: 5}).split('. ').length, 5);
});
test('paragraph sentences count is 10 when option sentences = -1', t => {
t.is(paragraph({sentences: -1}).split('. ').length, 10);
});
test('paragraph sentences words count when option sentences = 1 and wordsMin and wordsMax', t => {
t.true(paragraph({sentences: 1, wordsMin: 3, wordsMax: 5}).split(' ').length < 6);
t.true(paragraph({sentences: 1, wordsMin: 3, wordsMax: 5}).split(' ').length > 2);
});
test('paragraph sentences words count when option sentences = 1 and wordsMin and wordsMax is negative', t => {
t.true(paragraph({sentences: 1, wordsMin: -3, wordsMax: -5}).split(' ').length < 11);
t.true(paragraph({sentences: 1, wordsMin: -3, wordsMax: -5}).split(' ').length > 4);
});