forked from Jameskmonger/getfunctionname
/
test.js
28 lines (23 loc) · 750 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
"use strict";
var test = require('modunit');
var getFunctionName = require('./index');
test('it returns the correct function name for a function', (t, expected, func) => {
let returned = getFunctionName(func);
t.assert.equal(expected, returned);
}, [
['aFunction', function aFunction () { }],
['someOtherFunction', function someOtherFunction() { }],
['A_FUNCTION_IN_CAPITALS', function A_FUNCTION_IN_CAPITALS() { }]
]);
test('it returns \'anonymous\' for a lambda function', t => {
t.assert.equal(
getFunctionName(() => {}),
'anonymous'
);
});
test('it returns \'anonymous\' for an unnamed function', t => {
t.assert.equal(
getFunctionName(function () { }),
'anonymous'
);
});