-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
34 lines (29 loc) · 905 Bytes
/
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
29
30
31
32
33
34
import test from 'ava';
import has from '.';
test('main', t => {
// Error Handling
t.throws(() => {
has(123);
}, {
instanceOf: TypeError,
message: 'Expected input to be a string, got number'
});
t.throws(() => {
has('123', 123);
}, {
instanceOf: TypeError,
message: 'Expected substring to be a string or array, got number'
});
// Single substring
t.is(has('unicorns', 'uni'), true);
t.is(has('unicorns', 'UNI'), false);
t.is(has('unicorns', 'UNI', {caseSensitive: false}), true);
// Multiple
t.is(has('unicorns', ['uni', 'corn']), true);
t.is(has('unicorns', ['UNI', 'corn']), true);
t.is(has('unicorns', ['UNI', 'CORN']), false);
t.is(has('unicorns', ['UNI', 'CORN'], {caseSensitive: false}), true);
// Locale matching
t.is(has('\u0130', 'i', {caseSensitive: false}), true);
t.is(has('\u0130', ['i'], {caseSensitive: false}), true);
});