mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 00:10:07 +00:00
* test(utils): add urltobase64 test * test(utils): add token test * test(utils): fix missing import buffer * test(utils): add casting test * test(utils): add casting test * test(utils): fix use correct function
27 lines
963 B
TypeScript
27 lines
963 B
TypeScript
import { expect } from 'chai'
|
|
import { describe, it } from 'mocha'
|
|
import { Buffer } from 'node:buffer'
|
|
import { getBotIdFromToken, removeTokenPrefix } from '../src/token.js'
|
|
|
|
describe('token.ts', () => {
|
|
describe('token function', () => {
|
|
it('Will remove token prefix when Bot is prefixed.', () => {
|
|
expect(removeTokenPrefix('Bot discordeno is best lib')).to.be.equal('discordeno is best lib')
|
|
})
|
|
|
|
it('Will remove token prefix when Bot is NOT prefixed.', () => {
|
|
expect(removeTokenPrefix('discordeno is best lib')).to.be.equal('discordeno is best lib')
|
|
})
|
|
|
|
it('Will throw when token is undefined.', () => {
|
|
expect(() => removeTokenPrefix(undefined)).to.throw
|
|
})
|
|
})
|
|
|
|
describe('getBotIdFromToken function', () => {
|
|
it('Will get Bot Id from token', () => {
|
|
expect(getBotIdFromToken(`${Buffer.from('1033452747380494366').toString('base64')}.zawsxedcrftvgybhu`)).to.equal(1033452747380494366n)
|
|
})
|
|
})
|
|
})
|