-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9697834
commit 7ec5317
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
isAsyncFunction, | ||
isClass, | ||
isFunction, | ||
isGeneratorFunction, | ||
isMap, | ||
isPromise, | ||
isObject, | ||
isNumber, | ||
isSet, | ||
isRegExp, | ||
sleep, | ||
isProxy | ||
} from '../../src/util'; | ||
|
||
describe('/test/util/index.test.ts', () => { | ||
it('should test util method', async () => { | ||
expect(isAsyncFunction(async () => { | ||
})).toBeTruthy(); | ||
expect(isClass(class A { | ||
})).toBeTruthy(); | ||
expect(isFunction(() => { | ||
})).toBeTruthy(); | ||
expect(isGeneratorFunction(function* () { | ||
})).toBeTruthy(); | ||
expect(isMap(new Map())).toBeTruthy(); | ||
expect(isPromise(new Promise(() => { | ||
}))).toBeTruthy(); | ||
|
||
expect(isObject({})).toBeTruthy(); | ||
|
||
expect(isNumber(2)).toBeTruthy(); | ||
expect(isSet(new Set())).toBeTruthy(); | ||
expect(isRegExp(/^a/)).toBeTruthy(); | ||
expect(isProxy(new Proxy({}, {}))).toBeTruthy(); | ||
const startTime = Date.now(); | ||
await sleep(500); | ||
expect(Date.now() - startTime).toBeGreaterThanOrEqual(500); | ||
}); | ||
}); |