Files
30-seconds-of-code/test/functionName/functionName.test.js
2018-02-08 16:09:39 +02:00

27 lines
1001 B
JavaScript

const test = require('tape');
//const functionName = require('./functionName.js');
// Custom override for console.debug to check output.
let output = '';
const console = {};
console.debug = (x) => output = x;
// Override for testing
const functionName = fn => (console.debug(fn.name), fn);
test('Testing functionName', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof functionName === 'function', 'functionName is a Function');
functionName(Math.max);
t.equal(output, 'max', 'Works for native functions');
function fun(x) {return x;}
functionName(fun);
t.equal(output, 'fun', 'Works for functions');
const fn = x => x;
functionName(fn);
t.equal(output, 'fn', 'Works for arrow functions');
//t.deepEqual(functionName(args..), 'Expected');
//t.equal(functionName(args..), 'Expected');
//t.false(functionName(args..), 'Expected');
//t.throws(functionName(args..), 'Expected');
t.end();
});