Add is.any() and is.all() methods (#19)

This commit is contained in:
Kodie Grantham 2017-10-11 04:26:45 -05:00 committed by Sindre Sorhus
parent 75ac3cd574
commit 651f434eab
3 changed files with 81 additions and 0 deletions

30
test.js
View file

@ -427,3 +427,33 @@ test('is.empty', t => {
tempSet.add(1);
t.false(m.empty(tempSet));
});
test('is.any', t => {
t.true(m.any(m.string, {}, true, '🦄'));
t.true(m.any(m.object, false, {}, 'unicorns'));
t.false(m.any(m.boolean, '🦄', [], 3));
t.false(m.any(m.integer, true, 'lol', {}));
t.throws(() => {
m.any(null, true);
});
t.throws(() => {
m.any(m.string);
});
});
test('is.all', t => {
t.true(m.all(m.object, {}, new Set(), new Map()));
t.true(m.all(m.boolean, true, false));
t.false(m.all(m.string, '🦄', []));
t.false(m.all(m.set, new Map(), {}));
t.throws(() => {
m.all(null, true);
});
t.throws(() => {
m.all(m.string);
});
});