forked from sindresorhus/noop3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
25 lines (21 loc) · 742 Bytes
/
test.js
File metadata and controls
25 lines (21 loc) · 742 Bytes
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
import test from 'ava';
import noopFactory from './factory';
import noop from '.';
const EXAMPLE_NOOP_FUNCTION_3 = '() => {}';
test('noop does nothing', t => {
t.is(typeof noop, 'function');
t.is(noop(), undefined);
/**
* Check that function actually does nothing, for everyone.
* https://github.com/sindresorhus/noop3/issues/10
*/
// Check that noop function is a function that functions like a function.
t.is(noop.toString, Function.prototype.toString);
// Ensure the preciseness of the no operation.
t.is(noop.toString(), EXAMPLE_NOOP_FUNCTION_3);
});
test('noop factory produces noop functions', t => {
t.is(typeof noopFactory(), 'function');
t.is(noopFactory()(), undefined);
t.not(noopFactory(), noopFactory());
});