mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 08:20:08 +00:00
* test(utils): remove old test * test(utils): add color test * test(utils): fix import mocha * test(utils): fix test type error * test(utils): remove dev code * fix(utils): bucket not export all function * test(utils): add some test for bucket * fix(utils): close #2775 * test(utils): add test for permissions.ts * test(utils): fix missing mocha import * fix(utils): better fix for #2775
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { expect } from 'chai'
|
|
import { afterEach, beforeEach, describe, it } from 'mocha'
|
|
import sinon from 'sinon'
|
|
import { delay, formatImageURL } from '../src/utils.js'
|
|
|
|
describe('utils.ts', () => {
|
|
let clock: sinon.SinonFakeTimers
|
|
|
|
beforeEach(() => {
|
|
clock = sinon.useFakeTimers()
|
|
})
|
|
|
|
afterEach(() => {
|
|
sinon.restore()
|
|
clock.restore()
|
|
})
|
|
|
|
it('will', 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
|
|
})
|
|
})
|
|
|
|
it('[utils] format image url', () => {
|
|
expect(formatImageURL('https://skillz.is.pro')).to.be.equal('https://skillz.is.pro.jpg?size=128')
|
|
expect(formatImageURL('https://skillz.is.pro', 1024)).to.be.equal('https://skillz.is.pro.jpg?size=1024')
|
|
expect(formatImageURL('https://skillz.is.pro', 1024, 'gif')).to.be.equal('https://skillz.is.pro.gif?size=1024')
|
|
expect(formatImageURL('https://skillz.is.pro', undefined, 'gif')).to.be.equal('https://skillz.is.pro.gif?size=128')
|
|
})
|