fp/packages/scout/src/image.spec.js

33 lines
1.3 KiB
JavaScript
Raw Normal View History

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