mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-31 07:50:07 +00:00
* close test(utils): more test for Collection.ts #2793 * fix: after each not defined * close test(utils): more test for base64.ts #2796 * close test(utils): more test for casing.ts #2797 * test(utils): remove dev code * close #2799 * fix #2800 * close #2823 * test(utils): fix site move * close #2826 * refactor(utils): remove redundant if * close #2827 * close #2828
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { expect } from 'chai'
|
|
import { afterEach, beforeEach, describe, it } from 'mocha'
|
|
import sinon from 'sinon'
|
|
import { delay, hasProperty } from '../src/utils.js'
|
|
|
|
describe('utils.ts', () => {
|
|
let clock: sinon.SinonFakeTimers
|
|
|
|
beforeEach(() => {
|
|
clock = sinon.useFakeTimers()
|
|
})
|
|
|
|
afterEach(() => {
|
|
sinon.restore()
|
|
clock.restore()
|
|
})
|
|
|
|
describe('delay function', () => {
|
|
it('will delay/sleep for given time', async () => {
|
|
let delayEnded = false
|
|
delay(31).then(() => {
|
|
delayEnded = true
|
|
})
|
|
expect(delayEnded).to.be.false
|
|
await clock.tickAsync(30)
|
|
expect(delayEnded).to.be.false
|
|
await clock.tickAsync(31)
|
|
expect(delayEnded).to.be.true
|
|
})
|
|
})
|
|
|
|
describe('hasProperty funciton', async () => {
|
|
const obj = { prop: 'lts372005' }
|
|
|
|
it('will return true if it does have property', () => {
|
|
expect(hasProperty(obj, 'prop')).equal(true)
|
|
})
|
|
|
|
it('will return false if it does not have property', () => {
|
|
expect(hasProperty(obj, 'lts372005')).equal(false)
|
|
})
|
|
})
|
|
})
|