Tests for functionName
This commit is contained in:
@ -1,10 +1,23 @@
|
||||
const test = require('tape');
|
||||
const functionName = require('./functionName.js');
|
||||
|
||||
//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');
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
Test log for: Thu Feb 08 2018 15:13:49 GMT+0200 (GTB Standard Time)
|
||||
Test log for: Thu Feb 08 2018 15:59:54 GMT+0200 (GTB Standard Time)
|
||||
|
||||
> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
|
||||
> tape test/**/*.test.js | tap-spec
|
||||
@ -463,6 +463,9 @@ Test log for: Thu Feb 08 2018 15:13:49 GMT+0200 (GTB Standard Time)
|
||||
Testing functionName
|
||||
|
||||
√ functionName is a Function
|
||||
√ Works for native functions
|
||||
√ Works for functions
|
||||
√ Works for arrow functions
|
||||
|
||||
Testing functions
|
||||
|
||||
@ -1751,8 +1754,8 @@ Test log for: Thu Feb 08 2018 15:13:49 GMT+0200 (GTB Standard Time)
|
||||
√ Works with multiple promises
|
||||
|
||||
|
||||
total: 849
|
||||
passing: 849
|
||||
total: 852
|
||||
passing: 852
|
||||
duration: 2.4s
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user