Additional tests
This commit is contained in:
@ -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');
|
||||
});
|
||||
|
||||
@ -4,3 +4,9 @@ const {hz} = require('./_30s.js');
|
||||
test('hz is a Function', () => {
|
||||
expect(hz).toBeInstanceOf(Function);
|
||||
});
|
||||
test('hz returns a number', () => {
|
||||
expect(typeof hz(x => x)).toBe('number');
|
||||
});
|
||||
test('hz returns a number', () => {
|
||||
expect(typeof hz(x => x, 10)).toBe('number');
|
||||
});
|
||||
|
||||
@ -4,3 +4,10 @@ const {insertAfter} = require('./_30s.js');
|
||||
test('insertAfter is a Function', () => {
|
||||
expect(insertAfter).toBeInstanceOf(Function);
|
||||
});
|
||||
let e = document.createElement('div');
|
||||
e.setAttribute("id", "test");
|
||||
test('Does not throw error if the element exists', () => {
|
||||
expect(() => {
|
||||
insertAfter(e, '<span>test</span>');
|
||||
}).not.toThrow(TypeError);
|
||||
});
|
||||
|
||||
@ -4,3 +4,10 @@ const {insertBefore} = require('./_30s.js');
|
||||
test('insertBefore is a Function', () => {
|
||||
expect(insertBefore).toBeInstanceOf(Function);
|
||||
});
|
||||
let e = document.createElement('div');
|
||||
e.setAttribute("id", "test");
|
||||
test('Does not throw error if the element exists', () => {
|
||||
expect(() => {
|
||||
insertBefore(e, '<span>test</span>');
|
||||
}).not.toThrow(TypeError);
|
||||
});
|
||||
|
||||
@ -4,3 +4,6 @@ const {isBrowserTabFocused} = require('./_30s.js');
|
||||
test('isBrowserTabFocused is a Function', () => {
|
||||
expect(isBrowserTabFocused).toBeInstanceOf(Function);
|
||||
});
|
||||
test('isBrowserTabFocused is a Function', () => {
|
||||
expect(typeof isBrowserTabFocused()).toBe('boolean');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user