import { getProminentColor, rgbToHex, getStoryboard } from './image.ts' import { expect } from 'chai' import { describe } from 'mocha' import { dirname, basename, join, isAbsolute } from 'node:path'; import { fileURLToPath } from 'url'; export const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(fileURLToPath(import.meta.url)); describe('image', function () { describe('unit', function () { describe('getProminentColor', function () { it('should get a {String} hex code color', async function () { const color = await getProminentColor(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('integration', function () { 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 = 'http://38.242.193.246:8081/original-20250109T020401Z.mp4' const imagePath = await getStoryboard(url) expect(imagePath).to.match(/\.png/) }) }) }) })