Files
30-seconds-of-code/test/functionName/functionName.test.js
2018-06-18 15:54:48 +03:00

26 lines
615 B
JavaScript

const expect = require('expect');
let output = '';
const console = {};
console.debug = (x) => output = x;
const functionName = fn => (console.debug(fn.name), fn);
test('functionName is a Function', () => {
expect(functionName).toBeInstanceOf(Function);
});
functionName(Math.max);
test('Works for native functions', () => {
expect(output, 'max').toBe()
});
function fun(x) {return x;}
functionName(fun);
test('Works for functions', () => {
expect(output, 'fun').toBe()
});
const fn = x => x;
functionName(fn);
test('Works for arrow functions', () => {
expect(output, 'fn').toBe()
});