import { render } from "@opensea/testing-utils/render" import { composeStories } from "@storybook/react" import { screen } from "@testing-library/react" import React from "react" import { describe, expect, test } from "vitest" import { Image } from "./Image" import * as stories from "./Image.stories" const { VideoFrame, Original, Boost } = composeStories(stories) describe("", () => { test("optimizes ~ all params", () => { render( Nice image, ) const img = screen.getByRole("img", { name: "Nice image" }) expect(img).toHaveAttribute("class", "flex") expect(img).toHaveAttribute("height", "1000") expect(img).toHaveAttribute("width", "1000") expect(img).toHaveAttribute( "src", "https://i2.dev.seadn.io/ethereum/0x5af0d9827e0c53e4799bb226655a1de152a425a5/28bac4238ec3d45941c3e029abe8a124.png?h=1000&w=1000&q=50&fit=contain", ) }) test("optimizes ~ one dimension", () => { render( Nice image, ) const img = screen.getByRole("img", { name: "Nice image" }) expect(img).toHaveAttribute("class", "flex") expect(img).toHaveAttribute( "src", "https://i2.dev.seadn.io/ethereum/0x5af0d9827e0c53e4799bb226655a1de152a425a5/28bac4238ec3d45941c3e029abe8a124.png?w=1000", ) }) test("missing image", () => { render( Nice image, ) const img = screen.getByRole("img", { name: "Nice image" }) expect(img).toHaveAttribute("class", "flex") expect(img).toHaveAttribute("height", "1000") expect(img).toHaveAttribute("width", "1000") expect(img).toHaveAttribute( "src", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=", ) }) test("mp4 frame extraction", () => { render() const img = screen.getByRole("img", { name: "Nice image" }) expect(img).toHaveAttribute("class", "flex") expect(img).toHaveAttribute( "src", "https://i2.dev.seadn.io/earth.mp4?frame-time=1&w=1000", ) }) test("png frame extraction", () => { render( Nice image, ) const img = screen.getByRole("img", { name: "Nice image" }) expect(img).toHaveAttribute("class", "flex") expect(img).toHaveAttribute( "src", "https://i2.dev.seadn.io/ethereum/0x5af0d9827e0c53e4799bb226655a1de152a425a5/28bac4238ec3d45941c3e029abe8a124.png?w=1000", ) }) test("boost", () => { render() const img = screen.getByRole("img", { name: "Nice image" }) expect(img).toHaveAttribute("class", "flex") expect(img).toHaveAttribute( "src", "https://i2.dev.seadn.io/ethereum/0x5af0d9827e0c53e4799bb226655a1de152a425a5/28bac4238ec3d45941c3e029abe8a124.png?h=250&w=250", ) }) test("original", () => { render() const img = screen.getByRole("img", { name: "Nice image" }) expect(img).toHaveAttribute("class", "flex") expect(img).toHaveAttribute( "src", "https://raw2.seadn.io/ethereum/0xbd3531da5cf5857e7cfaa92426877b022e612cf8/28788fc3bd769b396cd74a6c53e68ae9.png", ) }) })