fp/packages/image/index.spec.ts

33 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-06-04 23:06:47 +00:00
2024-07-10 02:34:23 +00:00
import { getProminentColor, rgbToHex, getStoryboard } from './index.js'
2024-06-04 23:06:47 +00:00
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 () {
2024-07-10 02:34:23 +00:00
const mulberry = [255, 87, 51] as const
const screaminGreen = [77, 255, 106] as const
const amaranth = [227, 64, 81] as const
2024-06-04 23:06:47 +00:00
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/)
})
})
2024-06-04 23:06:47 +00:00
})