Additional tests

This commit is contained in:
Angelos Chalaris
2018-11-07 15:03:27 +02:00
parent 3fb91e74d2
commit 81c975289c
5 changed files with 29 additions and 7 deletions

View File

@ -1,20 +1,19 @@
const expect = require('expect');
const { functionName } = require('./_30s.js');
let output = '';
const functionName = fn => fn.name;
test('functionName is a Function', () => {
expect(functionName).toBeInstanceOf(Function);
});
test('Works for native functions', () => {
expect(functionName(Math.max)).toBe('max');
expect(typeof functionName(Math.max)).toBe('function');
});
function fun(x) {
function f(x) {
return x;
}
test('Works for functions', () => {
expect(functionName(fun)).toBe('fun');
test('Works for normal functions', () => {
expect(typeof functionName(f)).toBe('function');
});
const fn = x => x;
test('Works for arrow functions', () => {
expect(functionName(fn)).toBe('fn');
expect(typeof functionName(x => x)).toBe('function');
});