Skip to content

A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.

1003 B
Raw Blame
import { resolveThumbnailSource } from '../thumbnail'

const failed = (...sources: string[]) => new Set(sources)

describe('resolveThumbnailSource', () => {
  const image = {
    src: 'https://cdn.example.com/shot-full.jpg',
    thumbnail: 'https://cdn.example.com/shot-thumb.jpg'
  }

  it('uses the thumbnail when it is available', () => {
    expect(resolveThumbnailSource(image, failed())).toBe(image.thumbnail)
  })

  it('uses the full screenshot when the store sends no thumbnail', () => {
    expect(resolveThumbnailSource({ src: image.src }, failed())).toBe(image.src)
  })

  it('falls back to the full screenshot when the thumbnail failed', () => {
    expect(resolveThumbnailSource(image, failed(image.thumbnail))).toBe(
      image.src
    )
  })

  it('keeps the full screenshot when both sources failed', () => {
    // The placeholder is decided by the carousel, not here.
    expect(
      resolveThumbnailSource(image, failed(image.src, image.thumbnail))
    ).toBe(image.src)
  })
})