forked from mcmath/chai-iterator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
length-within.js
47 lines (44 loc) · 1.58 KB
/
length-within.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const {infiniteGenerator} = require('../fixtures');
const {err} = require('../helpers');
describe('expect/should: iterate.for.length.within(min, max)', function () {
it('passes if the target has lenght between @min and @max, inclusive', function () {
[2, 3, 5].should.iterate.for.length.within(2, 4);
[2, 3, 5].should.iterate.for.length.within(3, 3);
});
it('throws if the target does not have length between @min and @max, inclusive', function () {
err(function () {
[2, 3, 5].should.iterate.for.length.within(0, 2);
});
err(function () {
[2, 3, 5].should.iterate.for.length.within(4, 6);
});
});
it('works on infinite iterables', function () {
err(function () {
infiniteGenerator().should.iterate.for.length.within(200, 300);
});
});
it('maintains original assertion', function () {
[2, 3, 5].should.have.length.within(2, 4);
err(function () {
[2, 3, 5].should.have.length.within(4, 5);
});
});
});
describe('expect/should: not.iterate.for.length.within(n)', function () {
it('throws if the target has length between @min and @max, inclusive', function () {
[2, 3, 5].should.not.iterate.for.length.within(0, 2);
[2, 3, 5].should.not.iterate.for.length.within(4, 6);
});
it('passes if the target does not have length between @min and @max, inclusive', function () {
err(function () {
[2, 3, 5].should.not.iterate.for.length.within(2, 4);
});
err(function () {
[2, 3, 5].should.not.iterate.for.length.within(3, 3);
});
});
it('works on infinite iterables', function () {
infiniteGenerator().should.not.iterate.for.length.within(200, 300);
});
});