25 lines
1.0 KiB
TypeScript
25 lines
1.0 KiB
TypeScript
|
import { fpSlugify, getTmpFile, download } from './index.js'
|
||
|
import { expect } from 'chai'
|
||
|
import { describe } from 'mocha'
|
||
|
|
||
|
|
||
|
describe('utils', function () {
|
||
|
describe('fpSlugify', function () {
|
||
|
it('should remove all capitalization and uppercase and spaces and special characters', function () {
|
||
|
expect(fpSlugify('ProjektMelody')).to.equal('projektmelody')
|
||
|
expect(fpSlugify('CJ_Clippy')).to.equal('cjclippy')
|
||
|
})
|
||
|
})
|
||
|
describe('getTmpFile', function () {
|
||
|
it('should give a /tmp/<random>_<basename> path', function () {
|
||
|
expect(getTmpFile('my-cool-image.webp')).to.match(/\/tmp\/.*_my-cool-image\.webp/)
|
||
|
expect(getTmpFile('video.mp4')).to.match(/\/tmp\/.*_video\.mp4/)
|
||
|
})
|
||
|
}),
|
||
|
describe('download', function () {
|
||
|
it('should get the file', async function () {
|
||
|
const file = await download({ url: 'https://futureporn-b2.b-cdn.net/sample.webp' })
|
||
|
expect(file).to.match(/\/tmp\/.*sample\.webp$/)
|
||
|
})
|
||
|
})
|
||
|
})
|