ray-template/__test__/basic/isAsyncFunction.spec.ts
XiaoDaiGua-Ray 403fdd589a feat!: rebuild Ray Template as a monorepo
Share workspace packages between Ray Admin and the interactive docs.

BREAKING CHANGE: v6 is a new major line. v5 stays on legacy/v5.
2026-11-04 14:01:28 +08:00

34 lines
864 B
TypeScript

import { isAsyncFunction } from '../../apps/admin/src/utils/basic'
describe('isAsyncFunction', () => {
it('should return true if the function is async', () => {
const asyncFn = async () => {}
expect(isAsyncFunction(asyncFn)).toBe(true)
})
it('should return false if the function is not async', () => {
const syncFn = () => {}
expect(isAsyncFunction(syncFn)).toBe(false)
})
it('should return false if the function is not a function', () => {
const notFn = 'not a function'
expect(isAsyncFunction(notFn)).toBe(false)
})
it('should return false if the function is a class', () => {
class MyClass {}
expect(isAsyncFunction(MyClass)).toBe(false)
})
it('should return false if the function is a Promise', () => {
const promise = Promise.resolve('')
expect(isAsyncFunction(promise)).toBe(false)
})
})