Files
discordeno/packages/utils/tests/token.spec.ts
Fleny 919474069d chore: Migrate ESLint and prettier to Biome (#3634)
* Migrate eslint and prettier to biomejs

This does NOT include examples/bigbot as it has its own formatter

* Update to biome 1.8.0

* Readd dotenv dev dependency to rest

During a merge it got lost
2024-07-13 13:05:02 -05:00

27 lines
965 B
TypeScript

import { Buffer } from 'node:buffer'
import { expect } from 'chai'
import { describe, it } from 'mocha'
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)
})
})
})