-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.js
67 lines (57 loc) · 1.61 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*!
* falsey <https://github.com/jonschlinkert/falsey>
*
* Copyright (c) 2014-2018, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
require('mocha');
const assert = require('assert');
const falsey = require('./');
describe('falsey', function() {
it('should return false when truthy', function() {
assert(!falsey('1'));
assert(!falsey(1));
assert(!falsey([0]));
assert(!falsey(true));
assert(!falsey('true'));
assert(!falsey({a: 'b'}));
});
it('should return true when falsey', function() {
assert(falsey(''));
assert(falsey('0'));
assert(falsey(0));
assert(falsey(false));
assert(falsey(NaN));
assert(falsey(null));
assert(falsey(undefined));
});
it('should return "falsey" for `nil`', function() {
assert(falsey('nil'));
assert(falsey('NIL'));
});
it('should return "falsey" for `none`', function() {
assert(falsey('none'));
assert(falsey('None'));
});
it('should return "falsey" for `nope`', function() {
assert(falsey('nope'));
assert(falsey('nOPe'));
});
it('should return "falsey" for `no`', function() {
assert(falsey('no'));
assert(falsey('NO'));
});
it('should return "falsey" for `nada`', function() {
assert(falsey('nada'));
assert(falsey('Nada'));
});
it('should support custom "falsey" values', function() {
assert(!falsey('nil', []));
assert(!falsey('none', []));
assert(falsey('foo', ['foo', 'bar', 'baz']));
assert(falsey('bar', ['foo', 'bar', 'baz']));
assert(falsey('baz', ['foo', 'bar', 'baz']));
assert(!falsey('fez', ['foo', 'bar', 'baz']));
});
});