mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-21 02:40:08 +00:00
test(utils): remove old test
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
import { expect } from 'chai'
|
||||
import { describe, it } from 'mocha'
|
||||
// import { bigintToSnowflake, snowflakeToBigint } from '../src/bigint.js'
|
||||
let bigintToSnowflake: any, snowflakeToBigint: any
|
||||
|
||||
describe.skip('bigint.ts', () => {
|
||||
it('[bigint] - Transform a snowflake string to bigint', () => {
|
||||
const text = '130136895395987456'
|
||||
const big = 130136895395987456n
|
||||
const result = snowflakeToBigint(text)
|
||||
|
||||
expect(big).to.be.equal(result)
|
||||
expect(text).to.be.not.equal(result)
|
||||
})
|
||||
|
||||
it('[bigint] - Transform a bigint to a string', () => {
|
||||
const text = '130136895395987456'
|
||||
const big = 130136895395987456n
|
||||
const result = bigintToSnowflake(big)
|
||||
|
||||
expect(text).to.be.equal(result)
|
||||
expect(big).to.be.not.equal(result)
|
||||
})
|
||||
})
|
||||
@@ -2,7 +2,6 @@ import { expect } from 'chai'
|
||||
import { afterEach, beforeEach, describe, it } from 'mocha'
|
||||
import sinon from 'sinon'
|
||||
import { delay, formatImageURL } from '../src/utils.js'
|
||||
let hasProperty: any
|
||||
|
||||
describe('utils.ts', () => {
|
||||
let clock: sinon.SinonFakeTimers
|
||||
@@ -29,16 +28,6 @@ describe('utils.ts', () => {
|
||||
})
|
||||
})
|
||||
|
||||
const obj = { prop: 'lts372005' }
|
||||
|
||||
it.skip('[utils] hasProperty does HAVE property', () => {
|
||||
expect(hasProperty(obj, 'prop')).to.be.equal(true)
|
||||
})
|
||||
|
||||
it.skip('[utils] hasProperty does NOT HAVE property', () => {
|
||||
expect(hasProperty(obj, 'lts372005')).to.be.equal(false)
|
||||
})
|
||||
|
||||
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')
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import { expect } from 'chai'
|
||||
import { describe, it } from 'mocha'
|
||||
// import { validateLength } from '../src/validateLength.js'
|
||||
let validateLength: any
|
||||
|
||||
describe.skip(' ', () => {
|
||||
it('[utils] Validate length is too low', () => {
|
||||
expect(validateLength('test', { min: 5 })).to.be.equal(false)
|
||||
})
|
||||
|
||||
it('[utils] Validate length is too high', () => {
|
||||
expect(validateLength('test', { max: 3 })).to.be.equal(false)
|
||||
})
|
||||
|
||||
it('[utils] Validate length is NOT just right in between.', () => {
|
||||
expect(validateLength('test', { min: 5, max: 3 })).to.be.equal(false)
|
||||
})
|
||||
|
||||
it('[utils] Validate length is NOT too low', () => {
|
||||
expect(validateLength('test', { min: 3 })).to.be.equal(true)
|
||||
})
|
||||
|
||||
it('[utils] Validate length is NOT too high', () => {
|
||||
expect(validateLength('test', { max: 5 })).to.be.equal(true)
|
||||
})
|
||||
|
||||
it('[utils] Validate length is just right in between.', () => {
|
||||
expect(validateLength('test', { min: 3, max: 6 })).to.be.equal(true)
|
||||
})
|
||||
})
|
||||
@@ -1,39 +0,0 @@
|
||||
import { expect } from 'chai'
|
||||
import { afterEach, beforeEach, describe, it } from 'mocha'
|
||||
import { Buffer } from 'node:buffer'
|
||||
import Sinon from 'sinon'
|
||||
import nacl from 'tweetnacl'
|
||||
// import { verifySignature } from '../src/verifySignature.js'
|
||||
let verifySignature: any
|
||||
|
||||
describe.skip('verifySignature.ts', () => {
|
||||
let publicKey: Uint8Array
|
||||
let secretKey: Uint8Array
|
||||
let clock: Sinon.SinonFakeTimers
|
||||
|
||||
beforeEach(() => {
|
||||
clock = Sinon.useFakeTimers()
|
||||
;({ publicKey, secretKey } = nacl.sign.keyPair())
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
Sinon.restore()
|
||||
clock.restore()
|
||||
})
|
||||
|
||||
it('reutrn true if signature is verified', () => {
|
||||
const timestamp = Date.now().toString()
|
||||
const body = 'test body'
|
||||
const signature = nacl.sign.detached(Buffer.from(timestamp + body), secretKey)
|
||||
|
||||
const verifiedSignature = verifySignature({
|
||||
publicKey: Buffer.from(publicKey).toString('hex'),
|
||||
signature: Buffer.from(signature).toString('hex'),
|
||||
timestamp,
|
||||
body,
|
||||
})
|
||||
|
||||
expect(verifiedSignature.body).equal(body)
|
||||
expect(verifiedSignature.isValid).true
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user