import { expect, fixture, html } from '@open-wc/testing' import '../src/data-card/ox-card-thumb.js' import type { OxCardThumb } from '../src/data-card/ox-card-thumb.js' /* * The one picture cell of a catalog card (ADR-0117 amendment 2026-10-13): the picture whole, an icon when there is * none, at most one marker in the top-left corner, and a seam under it. */ describe('ox-card-thumb', () => { it('★ shows the picture whole, never cropped, with a seam under it', async () => { const thumb = await fixture(html``) const img = thumb.shadowRoot!.querySelector('img')! expect(img.getAttribute('alt')).to.equal('a board') expect(getComputedStyle(img).objectFit).to.equal('contain') expect(getComputedStyle(thumb).borderBottomStyle).to.equal('solid') expect(thumb.shadowRoot!.querySelector('[empty]')).to.equal(null) }) it('★ draws its icon when there is no picture, or the empty slot when one is given', async () => { const bare = await fixture(html``) expect(bare.shadowRoot!.querySelector('[empty] md-icon')!.textContent).to.equal('dashboard') const marked = await fixture(html`no picture`) const slot = marked.shadowRoot!.querySelector('slot[name="empty"]') as HTMLSlotElement expect(slot.assignedElements().map(e => e.id)).to.deep.equal(['mark']) }) it('★ says one thing in the corner, in its tone, and nothing when there is nothing to say', async () => { const quiet = await fixture(html``) expect(quiet.shadowRoot!.querySelector('[badge]')).to.equal(null) const warned = await fixture(html``) const badge = warned.shadowRoot!.querySelector('[badge]') as HTMLElement expect(badge.textContent).to.equal('not latest') expect(badge.getAttribute('tone')).to.equal('warn') expect(getComputedStyle(badge).position).to.equal('absolute') expect(getComputedStyle(badge).top).to.equal('6px') expect(getComputedStyle(badge).left).to.equal('6px') }) it('lays the default slot over the picture for an action that belongs to it', async () => { const thumb = await fixture(html``) const slot = thumb.shadowRoot!.querySelector('slot:not([name])') as HTMLSlotElement expect(slot.assignedElements().map(e => e.id)).to.deep.equal(['del']) }) })