editor.js/test/cypress/tests/utils.cy.ts
Ilya Maroz d7f1853ca1
deps(Cypress): upgrade library and related packages to latest versions, migrate config, fix type error (#2327)
* 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
2023-04-02 19:20:59 +01:00

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);
});
});