fp/packages/image/index.spec.ts

33 lines
1.3 KiB
TypeScript

import { getProminentColor, rgbToHex, getStoryboard } from './index.js'
import { expect } from 'chai'
import { describe } from 'mocha'
import path from 'node:path'
describe('image', function () {
describe('getProminentColor', function () {
it('should get a {String} hex code color', async function () {
const color = await getProminentColor(path.join(import.meta.dirname, './fixtures/sample.webp'))
expect(color).to.equal('#0878a8')
})
})
describe('rgbToHex', function () {
it('should convert color to hex {String} hexidecimal code', function () {
const mulberry = [255, 87, 51] as const
const screaminGreen = [77, 255, 106] as const
const amaranth = [227, 64, 81] as const
expect(rgbToHex(...mulberry)).to.equal('#ff5733')
expect(rgbToHex(...screaminGreen)).to.equal('#4dff6a')
expect(rgbToHex(...amaranth)).to.equal('#e34051')
})
})
describe('getStoryboard', function () {
this.timeout(1000*60*15)
it('should accept a URL and return a path to image on disk', async function () {
const url = 'https://futureporn-b2.b-cdn.net/projektmelody-chaturbate-2024-06-25.mp4'
const imagePath = await getStoryboard(url)
expect(imagePath).to.match(/\.png/)
})
})
})