mirror of
https://github.com/codex-team/editor.js
synced 2024-06-02 22:12:27 +02:00
d7f1853ca1
* deps: upgrade cypress and related libraries * chore: automate migrate cypress config, rename spec files * fix: custom commands types * chore: upgrade CHANGELOG.md * ci: upgrade cypress action to support new config file format * ci: remove container from firefox job, upgrade checkout action
70 lines
1.5 KiB
TypeScript
70 lines
1.5 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
import { isFunction } from '../../../src/components/utils';
|
|
|
|
/**
|
|
* Example of typical synchronous function
|
|
*/
|
|
function syncFunction(): void {}
|
|
|
|
/**
|
|
* Example of typical asynchronous function
|
|
*/
|
|
async function asyncFunction(): Promise<void> {}
|
|
|
|
const syncArrowFunction = (): void => {};
|
|
|
|
const asyncArrowFunction = async (): Promise<void> => {};
|
|
|
|
describe('isFunction function', () => {
|
|
it('should recognize sync functions', () => {
|
|
/**
|
|
* Act
|
|
*/
|
|
const commonFunctionResult = isFunction(syncFunction);
|
|
const arrowFunctionResult = isFunction(syncArrowFunction);
|
|
|
|
/**
|
|
* Assert
|
|
*/
|
|
expect(commonFunctionResult).to.eq(true);
|
|
expect(arrowFunctionResult).to.eq(true);
|
|
});
|
|
|
|
it('should recognize async functions', () => {
|
|
/**
|
|
* Act
|
|
*/
|
|
const commonFunctionResult = isFunction(asyncFunction);
|
|
const arrowFunctionResult = isFunction(asyncArrowFunction);
|
|
|
|
/**
|
|
* Assert
|
|
*/
|
|
expect(commonFunctionResult).to.eq(true);
|
|
expect(arrowFunctionResult).to.eq(true);
|
|
});
|
|
|
|
it('should return false if it isn\'t a function', () => {
|
|
/**
|
|
* Arrange
|
|
*/
|
|
const obj = {};
|
|
const num = 123;
|
|
const str = '123';
|
|
|
|
/**
|
|
* Act
|
|
*/
|
|
const objResult = isFunction(obj);
|
|
const numResult = isFunction(num);
|
|
const strResult = isFunction(str);
|
|
|
|
/**
|
|
* Assert
|
|
*/
|
|
expect(objResult).to.eq(false);
|
|
expect(numResult).to.eq(false);
|
|
expect(strResult).to.eq(false);
|
|
});
|
|
});
|